Forum

July 10th, 2011
You must be logged in to post Login Register

Search Forums:


 






jqGrid version 4.3.1 – potential sorting bugs when col name != col index

No Tags
UserPost

21:33
29/02/2012


SZMerge

New Member

posts 1

Let me preface with an explanation of what I was trying to do.

a) I have a date column which has a user friendly string date (i.e. Jan 5, 2010) which is displayed to the user and a hidden column (which is used as the sort index).  So my date column is configured like so:

this.m_colModelArray.push({ name: 'date', index: "dateTimeTicks" });

and my hidden index column is like so:

this.m_colModelArray.push({ name: 'dateTimeTicks', hidden: true, hidedlg: true });

Now, I've seen a couple potential bugs which occur when the name of a column is not the same as the index of a column as seen above.

1) When grouping by a column where the column name is not the same as the column index, "Loading" will be displayed and it will not be grouped.  In my case, I worked around it by commenting out the following section in addLocalData although it's really just a workaround.
                 /*if (typeof this.index != 'undefined') {

                        grindex = this.index;
                    }*/

2) When the column name is not the same as the column index, I also see an issue with trying to preserve the user's sorting choice.  In the onSortCol callback, the column name is given.  If I save this setting and then try to use it when creating the grid (using the sample code below) I find that the sort arrow will not be displayed for the correct column and the content will not be sorted.  Now, if I instead save the index instead of the name and use that in the call to sortname, the content will be sorted but the arrow will not appear over the column that was chosen by the user.  I suspect that the arrow is being put over the hidden column that is being used by the index.

Notes: this.m_gridTable is the jQuery object for the table.this.m_columnSortName is thename saved from the onSortCol callback.  Similarly sortorder contains the order from that callback.

    this.m_gridTable.jqGrid({
        autowidth: true,
        colModel: this.m_colModelArray,
        colNames: this.m_colNamesArray,
        data: this.m_dataArray,
        datatype: "local",
        grouping: true,
        loadonce: true,
        onSortCol: sortColumnCallback,
        shrinkToFit: true,
        sortname: this.m_columnSortName,
        sortorder: this.m_columnSortOrder

…..
    });

I worked around the problem by using the index for the sortname argument (to get it to sort correctly) and changing the following code in jqgrid:
            idn = ts.p.colModel[i].index || ts.p.colModel[i].name;
to
            idn = ts.p.colModel[i].index;

in order for the arrow to show up.

13:09
01/03/2012


tony

Sofia, Bulgaria

Moderator

posts 7010

Hello,

Thanks for the investigations – I will look into these.

Just a note for you last recommendation.

What will happen if the ts.p.colModel[i].index is not defined?


Regards


No Tags

About the jQuery Grid Plugin – jqGrid forum

Most Users Ever Online:

157


Currently Online:

23 Guests

Forum Stats:

Groups: 1

Forums: 7

Topics: 9596

Posts: 28792

Membership:

There are 10196 Members

There have been 448 Guests

There is 1 Admin

There are 2 Moderators

Top Posters:

OlegK – 1157

markw65 – 179

kobruleht – 144

phicarre – 126

YamilBracho – 124

Renso – 118

Administrators: admin (56 Posts)

Moderators: tony (7010 Posts), Rumen[Trirand] (81 Posts)




Comments are closed.
Privacy Policy   Terms and Conditions   Contact Information