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
Column Reordering - Using Local Array
21/07/2010
20:45
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

Afternoon!

I have been trying to get the columns to be sortable (reorder by dragging them) using a local array of data for the past week. I have gone through all of the demos, the message boards, and wiki to no avail. Can anyone look at the code for the page and tell me what I might be doing wrong please?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DT.....t;&gt;
<html xmlns="http://www.w3.org/1999/xhtml&q.....t;&gt;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/redmond/jquery-ui-1.8.2.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/grid.locale-en.js"></script>
<script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>
</head>

<body>

<table id="list47"></table>
<div id="plist47"></div>

<script type="text/javascript">
var rc = $("list47").jqGrid("getGridParam", "remapColumns")
if (rc && rc.length) {
   // rc[i] is the original position of the current i'th column
} else {
   // columns havent been reordered yet
}

var mydata = [
                {id:"01",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} ,
                {id:"02",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
                {id:"03",invdate:"2007-09-01",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
                {id:"04",invdate:"2007-10-04",name:"test",note:"note",tax:"10.00",total:"210.00"},
                {id:"05",invdate:"2007-10-05",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
                {id:"06",invdate:"2007-09-06",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
                {id:"07",invdate:"2007-10-04",name:"test",note:"note",tax:"10.00",total:"210.00"},
                {id:"08",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"21.00",total:"320.00"},
                {id:"09",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"11",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"12",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"13",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"14",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"15",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"16",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"17",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"18",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"19",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"21",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"22",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"23",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"24",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"25",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"26",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"27",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"28",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"29",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
        
        ];
        
    jQuery("#list47").jqGrid( {
            sortable: true,
            data: mydata,
            datatype: "local",
            colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
            colModel:[
                    {name:'id',index:'id', width:55},
                    {name:'invdate',index:'invdate', width:90},
                    {name:'name',index:'name', width:100},
                    {name:'amount',index:'amount', width:80, align:"right"},
                    {name:'tax',index:'tax', width:80, align:"right"},
                    {name:'total',index:'total', width:80,align:"right"},
                    {name:'note',index:'note', width:150, sortable:false}
            ],
            rowNum: 5,
            rowList: [5,10,15],
            pager: "#plist47",
            sortname: 'invdate',
            viewrecords: true,
            sortorder: "desc",
            caption: "Column Reordering"
    });
    jQuery("#list47").jqGrid('navGrid','#plist47',{add:false,edit:false,del:false});
</script>
</body>
</html>

22/07/2010
06:27
Avatar
yandaomin
China
Member
Members
Forum Posts: 3
Member Since:
20/07/2010
sp_UserOfflineSmall Offline

Hi loquae:

I use your html and test, I found it's normal. I use jqgrid 3.5 lib.

    I think your problem is about jqgrid lib. you download jqgrid 3.5lib and try it.

   the code see below,

   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>

<link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.2.custom.css" />
<link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/i18n/grid.locale-en.js"></script>
<script type="text/javascript" src="js/jquery.jqGrid.min.js"></script>
</head>

<body>

<table id="list47"></table>
<div id="plist47"></div>

<script type="text/javascript">
var rc = $("list47").jqGrid("getGridParam", "remapColumns")
if (rc && rc.length) {
   // rc[i] is the original position of the current i'th column
} else {
   // columns havent been reordered yet
}

var mydata = [
                {id:"01",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} ,
                {id:"02",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
                {id:"03",invdate:"2007-09-01",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
                {id:"04",invdate:"2007-10-04",name:"test",note:"note",tax:"10.00",total:"210.00"},
                {id:"05",invdate:"2007-10-05",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
                {id:"06",invdate:"2007-09-06",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
                {id:"07",invdate:"2007-10-04",name:"test",note:"note",tax:"10.00",total:"210.00"},
                {id:"08",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"21.00",total:"320.00"},
                {id:"09",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"11",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"12",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"13",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"14",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"15",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"16",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"17",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"18",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"19",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"21",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"22",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"23",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"24",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"25",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"26",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
                {id:"27",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
                {id:"28",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
                {id:"29",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
        
        ];
        
    jQuery("#list47").jqGrid( {
            sortable: true,
            data: mydata,
            datatype: "local",
            colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
            colModel:[
                    {name:'id',index:'id', width:55},
                    {name:'invdate',index:'invdate', width:90},
                    {name:'name',index:'name', width:100},
                    {name:'amount',index:'amount', width:80, align:"right"},
                    {name:'tax',index:'tax', width:80, align:"right"},
                    {name:'total',index:'total', width:80,align:"right"},
                    {name:'note',index:'note', width:150, sortable:false}
            ],
            rowNum: 5,
            rowList: [5,10,15],
            pager: "#plist47",
            sortname: 'invdate',
            viewrecords: true,
            sortorder: "desc",
            gridview: true,
                     pginput:true,
            caption: "Column Reordering"
    });
    jQuery("#list47").jqGrid('navGrid','#plist47',{add:false,edit:false,del:false});
</script>
</body>
</html>

22/07/2010
16:18
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

I currently have the most current version downloaded, but I'll try and download the 3.5 to see if that works.

Anyone else have any insight?

22/07/2010
22:36
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

So I realised that 3.5 does not have the reordering of columns.

Can someone please help me. I've gotta have this done for tomorrow (Friday).

Loq

23/07/2010
18:33
Avatar
RedSpawn
Member
Members
Forum Posts: 6
Member Since:
23/07/2010
sp_UserOfflineSmall Offline

hi there

i'm trying the same thing and i can't get it to work either....

what i've found is that in the working demo the header "tr" has an additional "ui-sortable" class which is missing in my local-data version

can someone help?

23/07/2010
18:36
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

So we're missing the class ui-sortable from the css file?

Is that what you're saying  RedSpawn?

23/07/2010
18:46
Avatar
RedSpawn
Member
Members
Forum Posts: 6
Member Since:
23/07/2010
sp_UserOfflineSmall Offline

no, the class is not missing in the css, it is missing in the html created by jqGrid.

there is something going wrong on creating the jqGrid object with local data and sortable columns.

i'm trying to recreate the demo with json data now.

23/07/2010
18:54
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

Well I have no database to connect to, so if you can figure something out that will work for the local data I'd be eternily grateful!

23/07/2010
19:56
Avatar
RedSpawn
Member
Members
Forum Posts: 6
Member Since:
23/07/2010
sp_UserOfflineSmall Offline

ok, i got it to work Embarassed

i had to load "jquery-ui-1.8.2.custom.min.js" Embarassed

sooooooooooo stupid!

i don't know if i should hope for you that you made the same mistake Wink

greetz

red

23/07/2010
19:57
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

What do you mean load it? It needs to go into the header of the page?

23/07/2010
20:01
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

Better yet, where do you get that file? I don't have it?!

23/07/2010
20:02
Avatar
RedSpawn
Member
Members
Forum Posts: 6
Member Since:
23/07/2010
sp_UserOfflineSmall Offline

yes, it's the ui part of jquery..

put this in the head:

<script type="text/javascript" language="javascript" src="business/jquery-ui-1.8.2.custom.min.js"></script>

and you can get it here:

http://jqueryui.com/download

23/07/2010
20:07
Avatar
loquae
Member
Members
Forum Posts: 8
Member Since:
21/07/2010
sp_UserOfflineSmall Offline

OMG that was it!!

More then 2 weeks and three people working on this only to find out that the file wasn't even in the download.

Thank you RedSpawn!!!

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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