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_TopicIcon
jqGrid with jsonstring sorting problem
08/04/2010
18:02
Avatar
Bauer
New Member
Members
Forum Posts: 1
Member Since:
08/04/2010
sp_UserOfflineSmall Offline

Hello,

my jqGrid load the data from a jsonstring. If I try to sort a column, the jqGrid duplicate the entries.

Example: Initial there are two entries in the grid, after clicking on a column there are 4 entries, than 8, 16, etc.

Here is my Code:

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/D.....t;&gt;
<html xmlns="http://www.w3.org/1999/xhtml&quot; dir="ltr" xml:lang="de">
    <head>
        <title>jqGrid Test</title>
        <link rel="stylesheet" type="text/css" href="css/style.css" />
        <link rel="stylesheet" type="text/css" href="js/lib/jquery/ui/themes/trontastic/jquery.ui.core.css" />
        <link rel="stylesheet" type="text/css" href="js/lib/jquery/ui/themes/trontastic/jquery.ui.theme.css" />
        <link rel="stylesheet" type="text/css" href="js/lib/jquery/jqgrid/css/ui.jqgrid.css" />
        <script type="text/javascript" src="js/lib/jquery/jquery-1.4.2.min.js"></script>
        <script type="text/javascript" src="js/lib/jquery/jqgrid/locale/grid.locale-de.js"></script>
        <script type="text/javascript" src="js/lib/jquery/jqgrid/jquery.jqGrid.min.js"></script>
        <script type="text/javascript" src="js/helper.js"></script>
        <script type="text/javascript">
        <!--
            $(function() {
                var gridJson = {
                    total: "1",
                    page: "1",
                    records: "2",
                    rows: [{id:"476329",name:"K-CY-329",metal:144,crystal:2746,deuterium:"0",distance:8.2,link:"Link"},
                           {id:"505778",name:"K-EB-778",metal:270,crystal:259,deuterium:59,distance:4.1,link:"Link"}]
                };
                
                $("#testGrid").jqGrid({
                    datatype: "jsonstring",
                    datastr: gridJson,
                    colNames: ["Id","Name","Metall","Kristall","Deuterium/Tritium","Distanz",""],
                    colModel: [
                        {name:"id",index:"id",width:60},
                        {name:"name",index:"name",width:80},
                        {name:"metal",index:"metal",width:80},
                        {name:"crystal",index:"crystal",width:80},
                        {name:"deuterium",index:"deuterium",width:160},
                        {name:"distance",index:"distance",width:80},
                        {name:"link",index:"link",width:40}],
                    rowNum: -1,
                    sortname: "distance",
                    sortorder: "desc",
                    jsonReader: {
                        repeatitems: false
                    }
                });
            });
        //-->
        </script>
    </head>
    <body>
        <table id="testGrid"><tr><td>&nbsp;</td></tr></table>
    </body>
</html>

Is something wrong with my code? It's only HTML and Javascript, no serverside code.

I used jqGrid 3.6.4 and jQuery 1.4.2.

Bauer

13/04/2010
14:34
Avatar
tony
Sofia, Bulgaria
Moderator
Members

Moderators
Forum Posts: 7721
Member Since:
30/10/2007
sp_UserOfflineSmall Offline

Hello,

The problem appear with this definition

<table id="testGrid"><tr><td>&nbsp;</td></tr></table>

In order to resolve do it so

$("#testGrid").empty().jqGrid({

...

});

Regards

Tony

For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
165 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