We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Additional Refresh function

Thread ID:

Created:

Updated:

Platform:

Replies:

88506 Jul 28,2009 02:16 AM Jul 30,2009 02:49 AM ASP.NET MVC (Classic) 3
loading
Tags: Grid
mac lee
Asked On July 28, 2009 02:16 AM

Dear Sir,

When developing web application, we have a form to enter selection criteria, then click the Query button on form to submit the criteria, in MVC mode, another action will handle this request and regenerate the content of grid,

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ShowGridActionX(string objNum)
{
DataModel model = new DataModel();
IList result = model.GetData(objNum);
return result.GridActions();
}

How do I simulate the post to this action and refresh the content of grid?

Balaji K [Syncfusion]
Replied On July 28, 2009 11:06 AM

Hi Mac,

Thank you for using Syncfusion products.

We can use the same form post in MVC.Please find the code snippet illustrating that.

[ASPX]
<% using (Html.BeginForm("ShowGridActionX","ControllerName")) { %>
<%=Html.TextBox("objNum") %>
<%=Html.Grid("Grid1")%>


<% } %>

[Controller]
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult ShowGridActionX(string objNum)
{
DataModel model = new DataModel();
IList result = model.GetData(objNum);
return result.GridActions();
}

Let us know if you have any issues.

Regards,
Balaji.

mac lee
Replied On July 29, 2009 06:02 AM

Not really.

I hope,
1. using Ajax when post back.
2. get the data entered in the form as parameter for controller.

If the grid has additional functionality to post back data in the form and refresh function, it is more usefull in real world application programming; otherwise, the sorting/paging/grouping function cannot working properly.

I've wrote a Javascript to do refrshing thru simulate the sorting postback when click a button on the form:

//var formID = "#QueryForm";
//var gridID = "ModifyUserGrid";

var firstField;
var sorting = "Ascending";

if ($(formID).valid() == false) {
return false; // do nothing
}

var grid = $find(gridID);
var col = grid.get_columns();
firstField = col[0].MappingName;

var PagingParams = {
RequestType: 2,
SortColumn: [firstField],
SortDirection: [sorting],
StartIndex: 0,
PageSize: 0, //grid.get_PageSize(),
ID: grid.get_id(),
SkinName: grid.get_SkinName()
};
var requestArgs = Sys.Serialization.JavaScriptSerializer.serialize(PagingParams);

var PagingParams = {
GridRequestParams: requestArgs,
ClientObject: grid.getClientObject(),
RequestType: 2,
SortColumn: [firstField],
SortDirection: [sorting],
StartIndex: 0,
PageSize: 0, //grid.get_PageSize(),
ID: grid.get_id(),
SkinName: grid.get_SkinName()
}

var f2 = $(formID).formToArray();
// Merge form data into PagingParams
var p1 = $.param(PagingParams);
var p2 = $.param(f2);
p1 = p1 + (p2 ? "&" : "") + p2;
grid._sendHtmlActionRequest(p1, "sorting", grid.get_ServerModePagingSortingMapper());

this is what I can do to bind data for grid when postback, but lost paging/sorting/grouping functions of grid cause no form data was posted back to controller.


Balaji K [Syncfusion]
Replied On July 30, 2009 02:49 AM

Hi Mac

Please find the code snippet to refresh the grid's content.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;