EasyUI Forum
April 25, 2024, 03:34:53 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: combogrid remote url is located to a local function or method, is it possible?  (Read 3438 times)
jianspf
Newbie
*
Posts: 12


View Profile Email
« 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},
    ]],
});
« Last Edit: February 26, 2021, 12:23:33 AM by jianspf » Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 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')
Logged
jianspf
Newbie
*
Posts: 12


View Profile Email
« Reply #2 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');                     
              }
            },
      });
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!