Forum

November 2nd, 2014
A A A
Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

The forums are currently locked and only available for read only access
sp_Feed Topic RSS sp_Related Related Topics sp_TopicIcon
custom formatter with xmlstring will not work
10/07/2013
13:06
Avatar
woron
New Member
Members
Forum Posts: 2
Member Since:
10/07/2013
sp_UserOfflineSmall Offline

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>

10/07/2013
14:48
Avatar
woron
New Member
Members
Forum Posts: 2
Member Since:
10/07/2013
sp_UserOfflineSmall Offline

ok, Im found the soluion Laugh

After convert the xmlstring from currently row to object, can search for currency!

formatter: function (cellvalue, options, rowObject) {
    var xml = rowObject.xml,
                        xmlDoc = $.parseXML( xml ),
                        $xml = $( xmlDoc ),
    $currency = $xml.find( "currency" );
    return cellvalue + ' ' + $currency.text()
}

thank you all

Forum Timezone: Europe/Sofia

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.com

Moderators: tony: 7721, Rumen[Trirand]: 81

Administrators: admin: 66

Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information