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:4.4.1; JQuery:1.8.2 - Sorting programmatically a loadonce jqgrid
15/03/2013
17:02
Avatar
Zwonimir
Member
Members
Forum Posts: 5
Member Since:
08/02/2013
sp_UserOfflineSmall Offline

Hi all guys!

I'm facing this bug  with jqGrid 4.4.1 and JQuery 1.8.2 both in IE9 and FF:

I defined a jqgrid with loadonce:true and some columns with a few of them that are hidden:

{ name: 'error', index: 'error_val', width: 20, resizable: false, align: 'center', fixed: true },

{ name: 'error_val', index: 'error_val', width: 0, hidden: true},

The column "error" is visible and shows an icon if there's an error in that row and is referred for the sorting ('index') to "error_val"

The column "error_val" is hidden and contains value '0' if there isn't an error and '1' if an error occurs.

Programmatically I put values in the cells of both columns with a statement like:

$('#grid').jqGrid('getGridParam', 'data')[$('#grid').jqGrid('getGridParam', '_index')[record_id]].error = '<img src="error.png" />';

$('#grid').jqGrid('getGridParam', 'data')[$('#grid').jqGrid('getGridParam', '_index')[record_id]].error_val = '1';

... then I wanna sort the column 'error' or 'error_val' programmatically when a button fires with a statement like

$('#grid').sortGrid('error', true, 'desc').setGridParam({ page: 1 }).trigger('reloadGrid');

..., so the rows with the error icon will be seen as the first rows in the first page. Problem is: when I sort with this last statement the rows appear sorted for the column 'error' but it involves only the rows of the visible page, if I have error icons in rows in page 2 or 3 they'll not appears in the first page after the osrting as I expect.

Thanks,

Zwonimir

18/03/2013
10:50
Avatar
Zwonimir
Member
Members
Forum Posts: 5
Member Since:
08/02/2013
sp_UserOfflineSmall Offline

a clue:

it works well if programmatically I pass through all pages:

var lastpage = $('#grid').getGridParam('lastpage');
if (lastpage == null || lastpage == undefined) {
     lastpage = 1;
}
if (lastpage > 1) {
     for (var idxPage = lastpage; idxPage>= 1; idxPage--) {
          $('#grid').setGridParam({ page: idxPage }).trigger('reloadGrid');
     }
     $('#grid').sortGrid('error_val', true, 'desc').trigger('reloadGrid');
} else {
     $('#grid').sortGrid('error_val', true, 'desc').setGridParam({ page: 1 }).trigger('reloadGrid');
}

Of course it's useless with a lot of pages, it takes too much time 🙂

Thx,

Zwonimir

21/03/2013
10:17
Avatar
Zwonimir
Member
Members
Forum Posts: 5
Member Since:
08/02/2013
sp_UserOfflineSmall Offline

ah it doesn't work even if I apply a filter :)

postdata = $('#grid').jqGrid('getGridParam','postData');

$.extend(postdata, { filters:'', searchField: 'error_val', searchOper: 'eq', searchString: '1'});

$('#grid').jqGrid('setGridParam', { search: true, postData: postdata }).trigger("reloadGrid",[{ page: 1 }]);

it filter only the records of the pages I've visited.

26/03/2013
10:03
Avatar
Zwonimir
Member
Members
Forum Posts: 5
Member Since:
08/02/2013
sp_UserOfflineSmall Offline

SOLVED!

I have to fire the sort with a timout statement or the rendering doesn't work.

setTimeout('SortGridErr()', 100);

function SortGridErr() {
     $('#grid').sortGrid('error_val', true, 'desc').setGridParam({ page: 1 }).trigger('reloadGrid');
}

Thx!

Zwon

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

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