EasyUI Forum
April 25, 2024, 09:50:22 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: How do Datagrid bind xml?  (Read 5818 times)
frankgao
Jr. Member
**
Posts: 53


View Profile Email
« on: February 08, 2018, 01:45:38 AM »

The datagrid request data type is xml,I want use loadFilter parse bind.
I debug console.log(xml);
but no data console.


Code:
        $('#gridmaster').datagrid({
            title: '',
            url: '/Offices/Dictionary/Reload',
            method: 'get',
            //dataType: "json",
            fit: true,
            toolbar: '#tb',
            fitColumns: true,
            rownumbers: true,
            striped: true,
            autoRowHeight: false,
            pageSize: 20,
            pagination: true,
            remoteSort: false,
            pageNumber: 1,
            pageList: [20,100,200,500],
            columns: [[
                { field: 'did', hidden: true, title: 'ID' },
                { field: 'name', title: 'Name', width: '110px', sortable: true },
                { field: 'desc', title: 'Descrition', width: '110px' }
            ]],
            queryParams: {
                formid: '0',
                pid: '0',
            },
            singleSelect: true,
            selectOnCheck: false,
            checkOnSelect: false,
            onLoadSuccess: function (data) {
            },
            onDblClickRow: function (rowIndex, rowData) {
                doEditPage('view');
            },
            loadFilter: function (xml) {
                console.log(xml);
           }
        });
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 08, 2018, 02:13:48 AM »

Please look at this topic https://www.jeasyui.com/forum/index.php?topic=1144.0
Logged
frankgao
Jr. Member
**
Posts: 53


View Profile Email
« Reply #2 on: February 08, 2018, 02:26:31 AM »


Yes,I had read this page.
I don't now the loadFilter is after load data working?
Because my Service  return xml data, I konw need use loadFilter  transfer to json.
but I console the xml,this no data show,actually it data is return.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: February 08, 2018, 02:37:24 AM »

The 'loadFilter' function is called before the 'onLoadSuccess' event. It must returns the filtered data.
Code:
loadFilter: function (xml) {
    console.log(xml);
    return xml;
},
onLoadSuccess: function(data){
console.log(data)
}
Logged
frankgao
Jr. Member
**
Posts: 53


View Profile Email
« Reply #4 on: February 08, 2018, 06:06:19 PM »

If my service return xml,the loadFilter method is not working.
I print the data,but it is no function.


Code:
url: '/Offices/DataDictionary/Reload',
            method: 'get',
            dataType: "json",// actually service return xml.


loadFilter: function (data) {
                console.log(data);
           }
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: February 08, 2018, 06:37:04 PM »

You can overwrite the 'loader' function to request any data from your remote server.
Code:
$('#dg').datagrid({
loader: function(param, success, error){
var opts = $(this).datagrid('options');
if (!opts.url) return false;
$.ajax({
type: opts.method,
url: opts.url,
data: param,
dataType: 'xml',  // the xml data format
success: function(data){
success(data);
},
error: function(){
error.apply(this, arguments);
}
});
},
loadFilter: function(data){
console.log(data);
return data;
}
});
Logged
frankgao
Jr. Member
**
Posts: 53


View Profile Email
« Reply #6 on: February 08, 2018, 09:12:59 PM »

Thanks!
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!