EasyUI Forum

General Category => General Discussion => Topic started by: rangaNadha on July 13, 2018, 07:23:46 AM



Title: Load datagrid combo filter dynamically from remote server
Post by: rangaNadha on July 13, 2018, 07:23:46 AM
Hi,

We have a requirement to show the combo filter in a datagrid dynamic data which it loads from remote server.

I have written the below code, there are not errors but list is not loading.

Can anyone please help how to load remote options dynamically in the datagrid combo box.

Code:

dg.datagrid('enableFilter',[{
            field:'personName',
            type:'combobox',
            valueField: 'id',
            textField: 'name',
            loader: listLoader,
            mode: 'remote'
         }
      ]);

var listLoader = function (){
var items = "";
$.ajax({
url: 'accTypesList.htm',
                        type:'POST',
                        cache:false,
                        success: function(data){
                               items = $.parseJSON(data, function(key,value){
                                                 return {
                                                        id: key,
                                                        name: value
                                                  };
                               });
                         }             
         });
return items;
}

[u]Response format example[/u]: {"1":"abc","2":"xyz","3":"asdf"}


Thanks in advance.


Title: Re: Load datagrid combo filter dynamically from remote server
Post by: jarry on July 14, 2018, 01:07:12 AM
The loader function should be defined as:
Code:
var listLoader = function (param,success,error){
$.ajax({
url: 'accTypesList.htm',
    type:'POST',
    cache:false,
    success: function(data){
       items = ...;
       success(items);
     }             
  });
}


Title: Re: Load datagrid combo filter dynamically from remote server
Post by: rangaNadha on July 17, 2018, 02:50:49 AM
Thanks Jarry, it is working now :)


Title: Re: Load datagrid combo filter dynamically from remote server
Post by: rangaNadha on July 17, 2018, 06:43:07 AM
Hi Jarry,

Need one more help, could you please tell me how to stop typing in combobox in the datagrid filter.


Title: Re: Load datagrid combo filter dynamically from remote server
Post by: jarry on July 17, 2018, 05:01:07 PM
Set the 'editable' property to false to disable the editing on the inputing box.


Title: Re: Load datagrid combo filter dynamically from remote server
Post by: rangaNadha on July 18, 2018, 12:07:56 AM
Thanks, it is working as expected.