EasyUI Forum
April 23, 2024, 09:25:44 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: Dynamic Json source  (Read 20912 times)
Ellipsis
Full Member
***
Posts: 113


View Profile WWW
« 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

Code:
$( "#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?

Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: June 06, 2012, 06:46:54 PM »

The customized loading functionality is available since 1.2.6.
Code:
$(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);
}
});
}
});
});
Logged
Ellipsis
Full Member
***
Posts: 113


View Profile WWW
« Reply #2 on: June 07, 2012, 02:01:22 AM »

 Huh Huh

No luck, the loader is not fired...

The code is inside a function that is called after loading the plugins with easyloader.

Code:
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);
}
});
}
});
« Last Edit: June 07, 2012, 02:59:09 AM by reno1979 » Logged
keja
Newbie
*
Posts: 26


View Profile Email
« Reply #3 on: April 25, 2021, 06:54:47 AM »

The above code does not work. Any update on this how does will it work ?



« Last Edit: April 25, 2021, 07:46:47 AM by keja » 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!