Miguel
Miguel

Reputation: 2079

how to clear gridview using javascript or jquery

i have a grid view and a file upload button on a page. I have users load their data to my site and i parse their files and load onto the gridview. Then using ajax i update the javascript/jquery I allow users to edit their data right on the gridview. My problem is somehting that should be simple to fix but yet im stumped. Once the user is ready to submit the gridview data for good i have an AJAX call to a webservice that i send all the information on the grid. Then i would like to clear the grid and basically start with a clean page again. However i cant seem to clear the grid view. The data just keeps refreshing in the control with the original data. I realize that it has to do with the fact that is bound on the server but i cant unbinded!. i have tried.

window.location.reload()

but all this does its get me a crappy message from firefox telling me that the page is going to refresh.

I saw this on this site from various people

Response.Redirect(Request.RawUrl);

however i don't know how i can trigger that from an Ajax call?. Can i? I'm doing everything through Ajax partly because is where im most comfortable, but i would hate to have to put another button on the page and make the user have to click that button to restart it seems silly. I would like to do a full page refresh on my command. Is there anyway to do this via AJAX? putting a server button does not seem feasible to me due to the fact that once i load data in grid view i use jquery data table and jeditable and work pretty much on the client. I'm open to suggestion, ideas, tips, anything at this point. So frustrated with what should be a simple task. Thanks in advance Miguel

Upvotes: 2

Views: 4105

Answers (2)

dana
dana

Reputation: 18145

If you must use server controls, you can wrap it in an UpdatePanel. This will make it ajax-enabled, but is pretty brute force.

There are nice libraries from companies like Telerik that have ajax-enabled controls. These cost some dough, but if you are doing a lot this it may be worth it.

Another option that does not support server templates/databinding is to use a jQuery based grid like jqQrid.

Upvotes: 1

Zeb Rawnsley
Zeb Rawnsley

Reputation: 2220

To force a full page refresh without postback you can set the window.location.href value to the current window.location.href

e.g.

Imagine our current scope is the success callback of your grid data ajax submission function, so when the page reloads all new data will be fetched.

//reload the page now that data has been updated.
window.location.href = window.location.href;

Upvotes: 4

Related Questions