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_Related Related Topics sp_TopicIcon
JqGrid's strange behavior.
09/04/2013
01:14
Avatar
ankit.zaveri
New Member
Members
Forum Posts: 1
Member Since:
09/04/2013
sp_UserOfflineSmall Offline

Hello Guys,

I am working on ASP.NET MVC application and using jqGrid 4.4.4 to bind my lsit to grid. I have three identical views whica contains same functionalities related to CRUD operations. I am using jqgrid's inline add functionality to add new row in grid. My two views are working perfect but my one view is not reloading grid items after adding a record or deleting a record from grid. Below are jqGrid code that I am using to build jqgrid.

$("#myGrid").jqGrid({

url: '@Url.Content("~/Content/GetData")',

datatype: "json",

colModel: [

{ name: 'ID', index: 'ID', label: 'ID', clickable: false, hidden: true, editable: false },

{ name: 'Title', index: 'Title', label: 'Brand', width: 150, editable: true, edittype: 'text', editrules: { required: true, custom: true, custom_func: validateValue }, formoptions: { elmsuffix: '(*)' }, sortable: true },

//{ name: 'ModifiedOn', index: 'ModifiedOn', label: 'Modified on', width: 80, editable: false, sortable: true, formatter: 'date' },

{ name: 'Actions', width: 60, fixed: true, sortable: false, search: false, resize: false, formatter: 'actions', formatoptions: { keys: true, editbutton: true, delbutton: true } }

],

caption: "Grid Data",

mtype: "GET",

rowNum: 1000,

rowList: [10, 20, 30],

shrinkToFit: true,

width: 980,

height: 200,

jsonReader: {

root: "Rows",

page: "Page",

total: "Total",

records: "Records",

repeatitems: false,

userdata: "UserData",

id: 'ID'

},

onSortCol: function (index, columnIndex, sortOrder) {

var sortcolumn = index + " " + sortOrder;

if (sortstring.search(index) != -1) {

if (sortOrder == 'asc')

sortstring = sortstring.replace(index + " desc", index + " asc");

else

sortstring = sortstring.replace(index + " asc", index + " desc");

}

else {

if (sortstring != "")

sortstring = sortstring + "," + sortcolumn;

else

sortstring = sortcolumn;

}

$('#myGrid').jqGrid('setGridParam', { sortname: sortstring });

},

pager: '#pager1',

sortname: 'Title',

viewrecords: true,

sortorder: "desc",

scroll: true,

reloadAfterSubmit: true,

emptyrecords: 'No records to display...',

ajaxGridOptions: { cache: true },

loadonce: false,

editurl: '@Url.Content("~/Content/ManageData")',

});

$("#myGrid").jqGrid('navGrid', '#pager1', { edit: false, add: false, del: false, search: false });

jQuery("#myGrid").jqGrid('inlineNav', "#pager1", { edit: false });

The problem I was facing previously was, after adding a new row, grid was not updating on client side. so I have passed a jason keyword from my controller action and on reload the grid on AjaxSuccess event. See below code block.

$(document).ajaxSuccess(function (event, request, settings, exception) {

if ((request.responseText.toLowerCase() == ""add"") || (request.responseText.toLowerCase() == "add")) {

$("#myGrid").trigger('reloadGrid');

}

});

This is working fine for my two pages but somehow it's not reloading grid after adding/deleting item to/from grid. While looking at request, i found that after calling my controller action to add/update record, grid is not calling controller action to get grid data specifically for this page.

Please share your ideas with me if I am missing something here.

Thanks,

09/04/2013
11:46
Avatar
tony
Sofia, Bulgaria
Moderator
Members

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

Hello,

I do not think that this is  a jqGrid problem. If the other two identical grids work then I think the problem is in your server code.

Please check what you do at server side? What you return?

The way you refresh the grid I think is not correct. If you reload the grid try to reload it in setTimeout function.

The simple test would be - do not refresh it automaticaly - just add a record and refresh it with refresh button.

Regards

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:
33 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