Forum
13:06
10/07/2013
I would like the currency is displayed in the cell with price.
But the formatter has no access to the XML data with rowObject.
Hat anyone have any idea what it may be?
Here is a complete example code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="http://www.trirand.com/blog/jqgrid/themes/redmond/jquery-ui-custom.css" />
<link rel="stylesheet" type="text/css" href="http://www.trirand.com/blog/jqgrid/themes/ui.jqgrid.css" />
<script type="text/javascript" src="http://www.trirand.com/blog/jqgrid/js/jquery.js"></script>
<script type="text/javascript" src="http://www.trirand.com/blog/jqgrid/js/jquery-ui-custom.min.js"></script>
<script type="text/javascript" src="http://www.trirand.com/blog/jqgrid/js/i18n/grid.locale-en.js"></script>
<script type="text/javascript">
$.jgrid.no_legacy_api = true;
$.jgrid.useJSON = true;
</script>
<script type="text/javascript" src="http://www.trirand.com/blog/jqgrid/js/jquery.jqGrid.js"></script>
<script type="text/javascript">
//<![CDATA[
/*global $ */
/*jslint devel: true, browser: true */
var xml_data_global = "<?xml version='1.0' encoding='UTF-8'?>" +
"<Order>" +
" <Item>" +
" <ItemAttributes>" +
" <pos_no>1</pos_no>" +
" <article_number></article_number>" +
" <quantity>1.0</quantity>" +
" <descrtiption>Article description</descrtiption>" +
" <price_total>3023.0</price_total>" +
" <currency>USD</currency>" +
" </ItemAttributes>" +
" </Item>" +
"</Order>";
$(document).ready(function () {
'use strict';
myGrid = jQuery("#list"),
myGrid.jqGrid({
datastr : xml_data_global,
datatype: 'xmlstring',
colModel: [
{ name: 'pos_no', index: 'pos_no', width: 50 },
{ name: 'descrtiption', index: 'descrtiption', width: 200 },
{ name: 'price_total', index: 'price_total', width: 200,
formatter: function (cellvalue, options, rowObject) {
return cellvalue + ' ' + rowObject.currency
}},
{ name: 'currency', index: 'currency', width: 100 }
],
xmlReader: {
root : "Order",
row: "Item",
repeatitems: false,
id: "pos_no"},
sortname: 'pos_no',
viewrecords: true,
rownumbers: true,
sortorder: "desc",
height: "100%",
pager: '#pager',
caption: ""
});
});
//]]>
</script>
</head>
<body>
<table id="list"><tr><td/></tr></table>
<div id="pager"></div>
</body>
</html>
14:48
10/07/2013
ok, Im found the soluion
After convert the xmlstring from currently row to object, can search for currency!
var xml = rowObject.xml,
xmlDoc = $.parseXML( xml ),
$xml = $( xmlDoc ),
$currency = $xml.find( "currency" );
return cellvalue + ' ' + $currency.text()
}
thank you all
Most Users Ever Online: 715
Currently Online:
37 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66