EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: frankgao on February 08, 2018, 01:45:38 AM



Title: How do Datagrid bind xml?
Post by: frankgao 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);
           }
        });


Title: Re: How do Datagrid bind xml?
Post by: stworthy on February 08, 2018, 02:13:48 AM
Please look at this topic https://www.jeasyui.com/forum/index.php?topic=1144.0


Title: Re: How do Datagrid bind xml?
Post by: frankgao on February 08, 2018, 02:26:31 AM
Please look at this topic https://www.jeasyui.com/forum/index.php?topic=1144.0

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.


Title: Re: How do Datagrid bind xml?
Post by: stworthy 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)
}


Title: Re: How do Datagrid bind xml?
Post by: frankgao 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);
           }


Title: Re: How do Datagrid bind xml?
Post by: stworthy 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;
}
});


Title: Re: How do Datagrid bind xml?
Post by: frankgao on February 08, 2018, 09:12:59 PM
Thanks!