Title: Dynamic Json source
Post by: Ellipsis on June 06, 2012, 09:50:41 AM
When using combogrid, combobox, datagrid etc I prefer the use of a dynamic Json source. I currently use the autocomplete function of easyUI and it has the extra options: minLength and Data. The data option enables you to send parameters with the Json URL, example : http://jqueryui.com/demos/autocomplete/#remote-jsonp (http://jqueryui.com/demos/autocomplete/#remote-jsonp) $( "#city" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "http://ws.geonames.org/searchJSON", dataType: "jsonp", data: { featureClass: "P", style: "full", maxRows: 12, name_startsWith: request.term }, //// etc etc , minLength: 2,
//etc etc
Is this possible for the datagrid in easyUI, it would make the function so much more complete. For example to create a datagrid based on what is typed in the input field... Or is it already possible?
Title: Re: Dynamic Json source
Post by: stworthy on June 06, 2012, 06:46:54 PM
The customized loading functionality is available since 1.2.6. $(function(){ $('#cc').combogrid({ mode: 'remote', //hasDownArrow: false, width: 200, panelWidth: 400, fitColumns: true, idField: 'geonameId', textField: 'adminName1', columns: [[ {field:'name',title:'Name',width:80}, {field:'adminName1',title:'adminName1',width:180}, {field:'countryName',title:'countryName',width:180} ]], onBeforeLoad: function(param){ if (!param.q || param.q.length<2) return false; }, loader: function(param,success,error){ $.ajax({ url: 'http://ws.geonames.org/searchJSON', dataType: 'jsonp', data: { featureClass: 'P', style: 'full', maxRows: 12, name_startsWith: param.q }, success: function(data){ success(data.geonames); }, error: function(){ error.apply(this, arguments); } }); } }); });
Title: Re: Dynamic Json source
Post by: Ellipsis on June 07, 2012, 02:01:22 AM
??? ??? No luck, the loader is not fired... The code is inside a function that is called after loading the plugins with easyloader. jQuery('#studiegidsnummer').combogrid({ mode: 'remote', width: 200, panelWidth: 400, fitColumns: true, idField: 'label', textField: 'title', columns:[[ {field:'title',title:'titel',width:200}, {field:'parentTemplateId',title:'Studiegidsnr.',width:200} ]], onBeforeLoad: function(param){ if (!param || param.length<2) return false; }, loader: function(param,success,error){ jQuery.ajax({ url: 'ajax?action=getSISCoursesJSON', dataType: 'jsonp', data: { catalogNumber: param.q+'%' }, success: function(data){ success(data.courseRecordSet); }, error: function(){ error.apply(this, arguments); } }); } });
Title: Re: Dynamic Json source
Post by: keja on April 25, 2021, 06:54:47 AM
The above code does not work. Any update on this how does will it work ?
|