EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jianspf on February 26, 2021, 12:19:21 AM



Title: combogrid remote url is located to a local function or method, is it possible?
Post by: jianspf on February 26, 2021, 12:19:21 AM
If combogrid remoteurl could be located to a local function or method, is it possible?
I want local filter in combogrid like remote url filter,but I don't want to visit the server url frequently,
local filter just locate the searchword in the full datagrid list,I want only show the filtered results in the panel by local filter model,
if remote url could be located to a local function or method, it will be solved.
Or anybody can provide another solution?

I tried another solution,that is put a onValidate event to combogrid and when i type something to query,i can get a new filtered results but how can i reload the combogrid data list? i need to change the datalist dynamiclly, is it possible?

this is the code:
Code:
				$("#wldw").combogrid({
panelWidth: 500,
   idField:'id',
   textField:'fullname',
   mode:'local',
   data:fcombodata,
   onValidate:function(f){
let fv = $("#wldw").combogrid('getText').trim();
    fcombodata = [];
    for(let i=0;i<combodata_cust.length;i++){
      if(combodata_cust[i]['id'].indexOf(fv)>=0||combodata_cust[i]['fullname'].indexOf(fv)>=0){
  fcombodata.push(combodata_cust[i]);
    }
    }
       //$("#wldw").combogrid('loadData',fcombodata);
    },
    columns:[[
          {field:'id',title:'ID',align:'center',width:80},
          {field:'fullname',title:'Name',align:'center',width:240},
          {field:'sword',title:'SearchWord',align:'center',width:80},
    ]],
});


Title: Re: combogrid remote url is located to a local function or method, is it possible?
Post by: jarry on February 26, 2021, 07:01:40 AM
You can call 'enableFilter' method to filter datagrid rows locally. Make sure to download the filtering extension from https://www.jeasyui.com/extension/datagrid_filter.php
Code:
$('#cc').combogrid('grid').datagrid('enableFilter')


Title: Re: combogrid remote url is located to a local function or method, is it possible?
Post by: jianspf on February 26, 2021, 07:13:50 PM
You can call 'enableFilter' method to filter datagrid rows locally. Make sure to download the filtering extension from https://www.jeasyui.com/extension/datagrid_filter.php
Code:
$('#cc').combogrid('grid').datagrid('enableFilter')

It works!!!! thank you jarry...i revised the code:

      $("#wldw").combogrid({
           panelWidth: 500,
           width: 220,
           height: 30,
            fitColumns: false,
            onValidate:function(f){
               let fv = $(this).combogrid('getText');
               let fvlen = fv.length;
               if(fv.trim()!=''&&fv.substring((fvlen-1))==' '){
                   $(this).combogrid('grid').datagrid('addFilterRule', {
                      field: 'fullname',
                      op: 'contains',
                      value: fv.trim(),
                   });
                   $(this).combogrid('grid').datagrid('addFilterRule', {
                      field: 'sword',
                      op: 'contains',
                      value: fv.trim(),
                   });                  
                  $(this).combogrid('grid').datagrid('doFilter');
               }
              if(fv.trim()==''){
                   $(this).combogrid('grid').datagrid('addFilterRule', {
                      field: 'fullname',
                      op: 'contains',
                      value: fv.trim(),
                   });
                   $(this).combogrid('grid').datagrid('addFilterRule', {
                      field: 'sword',
                      op: 'contains',
                      value: fv.trim(),
                   });                  
                  $(this).combogrid('grid').datagrid('doFilter');                     
              }
            },
      });