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
Reloading grid after submitting(edit/add/delete)
28/05/2013
15:51
Avatar
Vinod Kumar
New Member
Members
Forum Posts: 2
Member Since:
28/05/2013
sp_UserOfflineSmall Offline

Hi Everyone,

I am new to the jqgrid and I recently builded one grid with the example I got form one of the forums. I got stuck at reloading the form after editing/adding/deleting. I have searched and worked on this for the last two days but I found nothing. Please help me on this.

Here is the code I am using

jQuery(document).ready(function(){

$.ajax(

{

type: "POST",

url: someurl

data: somedata

dataType: "json",

success: function(result)

{

colD = result.colData;

colN = result.colNames;

colM = result.colModel;

jQuery("#list").jqGrid({

jsonReader : {

repeatitems: false,

root:"dataset",

cell: "",

id: "Id",

total:"total",

page:"page",

records:"records"

},

url:someurl

postData:somedata

datatype: 'jsonstring',

mtype: 'POST'

datastr : colD,

colNames: colN,

colModel: colM,

pager: '#pager',

rowNum: 10,

rowList: [10, 20, 50],

sortname: 'Id',

viewrecords: true,

sortorder: "asc",

height: "75%",

gridview: true,

loadonce:true,

editurl:editurl

loadComplete: function(data){

jQuery("#list").jqGrid('navGrid','#pager',{edit:true,add:true,del:true,search:true,refresh:true,view:true},

{

beforeShowForm:function(form)

{

 //some code to hide the columns

},

afterSubmit:function(response,postdata)

{

$("#list").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');

return [true,"",''];

},

closeAfterEdit: true

}

);

}

jQuery("#list").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});

},

loadError : function(xhr,st,err) {

alert('Some thing is wrong...');

jQuery("#rsperror").html("Type: " + st + "; Response: " + xhr.status + " " + xhr.statusText + " Details: " + err);

}

})

},

error: function(x, e)

{

alert('Ready State: ' + x.readyState + " Status: "+ x.status +" Error Message: "+ e.msg + " Error:" + e);

jQuery("#rsperror").html("; Response: " + x.status + " " + x.statusText + " Details: " + e);

}

});

 </script>

</head>

<body>

Here I am using loadOnce=true. I am using latest jqgrid(4.5.2) From this site /blog/jqgrid/jqgrid.html I came to know that searching is possible for local data also from 3.7 version onwards but searching,filtering and refreshing is also not working for me. I need to change the datastr after reloading the grid.I tried to catch the result after reloading the grid by using ajaxGridOptions success method but grid got struck and showing Loading message..and doesn't enter into loadComplete. Confused

Thanks,

Vinod

15/10/2013
16:43
Avatar
maxif
Uruguay
Member
Members
Forum Posts: 3
Member Since:
05/10/2010
sp_UserOfflineSmall Offline

Hi Vinod, I have recently upgraded from version 3.8 to 4.4.5 and have de same problem as you.

I use exactly de same method, loading from jason with loadonce activated, so page resizing and sorting is made client side.

When editng rows with form, the grid does not reload the modified data.

I think this is either a bug or a change of behavior, I couldnt find any documentation on this.

Even using the edit option reloadAfterSubmit:true does not refresh de grid.

I think it could be because of datatype is set to local when using loadonce and in previous versions this setting was ignored and performed the ajax request.

The solution I found is to override afterComplete in editing options and trigger the reload manually.

Did you find any other way to do it?

Bye

17/10/2013
11:59
Avatar
Vinod Kumar
New Member
Members
Forum Posts: 2
Member Since:
28/05/2013
sp_UserOfflineSmall Offline

Hi maxif,

       Yes, you are correct.The reloading is not performed due to the datatype got change to local(loadonce is true).You need to reload the grid manually in afterSubmit function for form editing. You need to set the datatype to json before triggering reload event.

$("#gridid").jqGrid('setGridParam',{datatype:'json'}).trigger('reloadGrid');

Forum Timezone: Europe/Sofia

Most Users Ever Online: 715

Currently Online:
30 Guest(s)

Currently Browsing this Page:
2 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