jQWidgets Forums

jQuery UI Widgets Forums Plugins Data Adapter get variable value from dataadapter

This topic contains 2 replies, has 2 voices, and was last updated by  claudegel 10 years, 4 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • get variable value from dataadapter #68010

    claudegel
    Participant

    I’ve set a dataadapter to get a value from mysql database and need to pass that value to a variable used in another section of my script
    dataadapter is like this

    var source_form =
    		{
    			datatype: "json",
                type:	"POST",
                datafields: [
                    { name: 'AUTO_INCREMENT' }
                ],
                url: url,
                async: false,
                data: {
            		select: true,
            		dbase: "information_schema.tables",
            		numrow: "1",
            		filtre: "table_name = 'formadmin' AND table_schema = DATABASE( )",
            		ordre: "-",
                	field: "AUTO_INCREMENT"
            	}
    		};
    	var dataAdapter3 = new $.jqx.dataAdapter(source_form, {
    		loadComplete: function (records) {
    			var records = dataAdapter3.records;
    			var record = records[0];
    			

    $(‘#formulaire’).html(“Formulaire no: ” + record.AUTO_INCREMENT);
    var form_no = record.AUTO_INCREMENT;
    },

    });`

    I get the value from my php script and can print it via

    $('#formulaire').html("Formulaire no: " +  record.AUTO_INCREMENT);
    ...
    <div id="formulaire"></div>
    

    but I cannot get the var form_no to be available in other part of my script like in grid so I can send it back to mysql with other info

    How do I get the form_no value outside the dataadapter section

    get variable value from dataadapter #68014

    Peter Stoev
    Keymaster

    Hi claudegel,

    If data is loaded through jqxDataAdapter, you can access the data using dataAdapter.records. dataAdapter.records[0] gives you the first record, dataAdapter.records[1], the second and so on. In your code you have one data field – AUTO_INCREMENT so you can use only dataAdapter.records[index].AUTO_INCREMENT for accessing your records data. To send that value to a server you can use jQuery Ajax and set it’s data parameter to your JSON variable.

    Best regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

    get variable value from dataadapter #68047

    claudegel
    Participant

    Thanks it work perfectly

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.