EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: ahybits on October 18, 2017, 07:42:56 AM



Title: Auto Execute Combogrid Loader
Post by: ahybits 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
            }
        });


Title: Re: Auto Execute Combogrid Loader
Post by: Pierre 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)


Title: Re: Auto Execute Combogrid Loader
Post by: ahybits 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


Title: Re: Auto Execute Combogrid Loader
Post by: stworthy 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'
});


Title: Re: Auto Execute Combogrid Loader
Post by: ahybits 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)


Title: Re: Auto Execute Combogrid Loader
Post by: ahybits 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


Title: Re: Auto Execute Combogrid Loader
Post by: stworthy 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)


Title: Re: Auto Execute Combogrid Loader
Post by: ahybits 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