jQuery UI Widgets Forums Plugins Data Adapter pass dynamic variable to DataAdapter

Tagged: 

This topic contains 2 replies, has 2 voices, and was last updated by  Hugo 5 years, 3 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
  • pass dynamic variable to DataAdapter #62232

    Hugo
    Participant

    Hello guys,

    You can pass dynamic variable to DataAdapter depending on certain condition?

    example:

    var source = new $.jqx.dataAdapter({
         datatype: 'json',
         datafields:[{ name: 'field' }, { name: 'field' }],
         url: 'mypage.php',
         data: { mydata: ????? }, // <-- variable
         cache: false,
         async: false
    });
    
    $('$jqxGrid').jqxGrid({
       ...
       columns: [
          { 
              text: 'my',
              datafield: 'my',
              width: 200,
              columntype: 'dropdownlist',
              createeditor: function( row, cellvalue, editor ){
    	     editor.jqxDropDownList({ source: [], displayMember: 'field', valueMember: 'field' });
              },
    	  initeditor: function( row, cellvalue, editor, celltext ){
    	     /*
                    Loads the source based on cellvalue
                 */
    	     editor.jqxDropDownList({ source: source, displayMember: 'field', valueMember: 'field' });
              },
              .. etc
       ]
    });
    pass dynamic variable to DataAdapter #62242

    Peter Stoev
    Keymaster

    Hi Hugo,

    You can define the dataAdapter’s formatData callback. It is called on each dataBind call.

    var dataAdapter = new $.jqx.dataAdapter(source,
        {
            formatData: function (data) {
                $.extend(data, {
                    featureClass: "P",
                    style: "full",
                    maxRows: 50
                });
    
                return data;
            }
        }
    );

    Best Regards,
    Peter Stoev

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

    pass dynamic variable to DataAdapter #62299

    Hugo
    Participant

    Thanks @Peter Stoev 😀

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

You must be logged in to reply to this topic.