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
Problem in sorting on client side
26/07/2011
14:19
Avatar
surajpatil9211
Member
Members
Forum Posts: 4
Member Since:
26/07/2011
sp_UserOfflineSmall Offline

Hi,

I want to implement sorting on client side.

I have included loadonce true & also tried things that I found on web but none of them working for me.

Here is my code

  <script type="text/javascript">

        var lastrow;

        $(function () {
            $("#UsersGrid").jqGrid({
                url: '../jqGridHandler.ashx?pname=mp',
                datatype: 'json',
                height: 'auto',
                rowTotal: 100,
                mtype: "GET",
                colNames: ['ID', 'Name', 'Description', 'Price', 'IsActive', 'Edit'],
                colModel: [
                        { name: 'pid', index: 'ID', align: 'center', width: 50, sortable: true, sorttype: "int" },
                        { name: 'name', width: 160, align: 'center', sortable: true, sorttype: "Text" },
                        { name: 'description', width: 250, align: 'center', sortable: true, sorttype: "Text" },
                        { name: 'price', width: 90, align: 'center', sortable: true, sorttype: "int" },
                        { name: 'isActive', width: 50, align: 'center', sortable: false },
                        { name: 'Edit', width: 50, align: 'center', sortable: false, edittype: 'select', formatter: 'showlink', formatoptions: { baseLinkUrl: 'CreatePackage.aspx', addParam: '&menuindex=1', idName: 'pid'} }                       
                    ],
                multiselect: false,

                onSelectRow: function (id) {
                    if (id && id !== lastrow) {
                        jQuery('#UsersGrid').restoreRow(lastrow);
                        //jQuery('#UsersGrid').editRow(id, true);
                        lastrow = id;
                    }
                },
                loadComplete: function () {
                    $("#UsersGrid").setGridParam({ datatype: 'json' });
                },
                onPaging : function(which_button) {
                    $("#UsersGrid").setGridParam({ datatype: 'json' });
                },
                rowNum: 9,
                rowList: [5, 10, 20, 30],
                pager: '#UsersGridPager',
                jsonReader: {
                    repeatitems: true
                },
                loadonce: true,
                sortable: true,
                viewrecords: true,
                sortname: 'ID',
                viewrecords: false,
                sortorder: 'desc',
                caption: 'Packages',
                editurl: "../jqGridHandler.ashx?pname=mp"
            });
            $("#UsersGrid").jqGrid('navGrid', '#UsersGridPager', { edit: false, add: false, del: true, search: false },
            {
                closeAfterEdit: true,
                reloadAfterSubmit: false
            },
            {
                closeAfterAdd: true,
                reloadAfterSubmit: false
            },
            {                
                beforeShowForm: function (formid) {
                    if (lastrow == 1) {
                        alert("This package can not be deleted.");
                        $("#" + formid).remove;
                    }
                },
                jqModal: false,
                closeOnEscape: true,
                reloadAfterSubmit: false
            });

        });
    </script>

27/07/2011
07:42
Avatar
surajpatil9211
Member
Members
Forum Posts: 4
Member Since:
26/07/2011
sp_UserOfflineSmall Offline

Here is the data grid is recieving.

{"page":1,"total":0,"records":2,"rows":[{"id":1,"cell":["1","Basic","Basic Free Package","0","yes","Edit"]},{"id":2,"cell":["2","Gold","Gold","1000","yes","Edit"]}]}

28/07/2011
07:50
Avatar
surajpatil9211
Member
Members
Forum Posts: 4
Member Since:
26/07/2011
sp_UserOfflineSmall Offline

I sorted out it myself.

It was just the problem with the index property of colModel,Index was suppose to be 'pid' instead of 'ID'.    🙂

So  you just have to provide

loadonce = true

& rowTotal

to make client side sorting & paging work & also the sorttype for the columns.

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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