EasyUI Forum
May 03, 2024, 12:13:06 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Auto Execute Combogrid Loader  (Read 7923 times)
ahybits
Newbie
*
Posts: 26


View Profile
« on: October 18, 2017, 07:42:56 AM »

I have a combogrid that works fine with the loader when we type text into it

how can I prepopulate the box with the lookup text to start \ execute the loader function so the results will appear in the same combogrid

Code:
 $('#txtUserLookup').combogrid({
            prompt: 'Enter Name to Lookup',
            idField: 'id',
            textField: 'fullname',
            url: '/users',
            method: 'get',
            mode: 'remote',
            columns: [[
                {field:'id',title:'id',width:80},
                {field:'fullname',title:'fullname',width:120},
                {field:'title',title:'title',width:120}
            ]],
            fitColumns: true,
            onBeforeLoad: function(param){
                if (!param.q || param.q.length<2) return false;
            },
            loader: function(param,success,error){
                $.ajax({
                    url: '/users',
                    data: {search: param.q},
                    success: function(result){
                        success(result.data);
                    }
                });
            },
            onSelect: function(index, row) {
               //blah blah blah
            }
        });
« Last Edit: October 18, 2017, 07:46:35 AM by ahybits » Logged
Pierre
Sr. Member
****
Posts: 439


View Profile Email
« Reply #1 on: October 18, 2017, 11:49:09 AM »

Did you checked this example: http://jeasyui.com/demo/main/index.php?plugin=ComboGrid&theme=material&dir=ltr&pitem=&sort=
maybe it helps you
(see Initialize Value for ComboGrid example)
Logged
ahybits
Newbie
*
Posts: 26


View Profile
« Reply #2 on: October 18, 2017, 01:37:55 PM »

I see the "value" field is populated, it was similar what i was doing which was setValue" -- but either case, it did not show the grid appear with the loader (filtered) results - it just sets the textbox value, doesnt imitate the loader function
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: October 18, 2017, 05:24:04 PM »

Try to set the 'queryParams' and 'value' properties to achieve it.
Code:
$('#txtUserLookup').combogrid({
queryParams: {
q: 'test'
},
value: 'test'
});
Logged
ahybits
Newbie
*
Posts: 26


View Profile
« Reply #4 on: October 19, 2017, 07:46:53 AM »

Thanks - Much better - The result shows in the combogrid

but ... It doesnt call the onSelect function until you actually got to the comboogrid and click on that result
I tried to do this after, but nothing
Code:
            $('#txtUserLookup').combogrid('selectRow',0)
Logged
ahybits
Newbie
*
Posts: 26


View Profile
« Reply #5 on: October 23, 2017, 06:57:17 AM »

anyone got any ideas - been trying a few things with no luck - just need a way to initiate onSelect
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #6 on: October 23, 2017, 06:24:22 PM »

The 'selectRow' method is defined in datagrid, please get the datagrid object before calling this method.
Code:
var grid = $('#txtUserLookup').combogrid('grid');
grid.datagrid('selectRow',0)
Logged
ahybits
Newbie
*
Posts: 26


View Profile
« Reply #7 on: October 26, 2017, 01:11:10 PM »

I get no errors now - but still not executing my onSelect automatically

            onSelect: function(index, row) { ..... }

I think I will just extract the code from the onSelect and make it a separate function and will call it it from after the selectRow \ selectRecord data result
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!