开发者

jqgrid generating xml only for selected row

开发者 https://www.devze.com 2023-02-08 15:14 出处:网络
My question is regarding generate 开发者_如何学Goxml , Is there a way to get only the selected rows inside of the xml and not all of the grid\'s rows??

My question is regarding generate 开发者_如何学Goxml ,

Is there a way to get only the selected rows inside of the xml and not all of the grid's rows??

Thank's In Advance.


You can do following

var selRowId = grid.jqGrid ('getGridParam', 'selrow');
if (selRowId) {
    var dataFromGrid = {row: grid.jqGrid ('getRowData', selRowId) };
    var xmldata='<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n<rows>\n'+
                  xmlJsonClass.json2xml (dataFromGrid, '\t') + '</rows>';
    alert(xmldata);
}

see here the modified demo.

UPDATED: If you need to add additional attributes to the <row> elements you should add properties started with '@'.

var selRowId = grid.jqGrid ('getGridParam', 'selrow');
if (selRowId) {
    var rowData = grid.jqGrid ('getRowData', selRowId);
    rowData["@foo"] = "bar";
    var xmldata='<?xml version="1.0" encoding="utf-8" standalone="yes"?>\n<rows>\n'+
                xmlJsonClass.json2xml ({row: rowData}, '\t') + '</rows>';
    alert(xmldata);
}

See the demo.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号