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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Filter functions Ajax

Thread ID:

Created:

Updated:

Platform:

Replies:

90846 Oct 21,2009 01:01 PM UTC Oct 30,2009 01:19 AM UTC ASP.NET MVC (Classic) 1
loading
Tags: Grid
Mladen Miljic
Asked On October 21, 2009 01:01 PM UTC

The idea is to filter a paging grid.

(How)Is it possible to update a paging grid by another form? For example:

View:
<%using (Ajax.BeginForm("FilterAction", new AjaxOptions() { UpdateTargetId = "Paging_Grid", OnBegin = "showPopup", OnSuccess = "hidePopup" }))
{%>
...Form elements...
<%} %>

Controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult FilterAction([DatePickerModel fromDate])
{
...process form fields and get data...
return JSON(data);
}

the result of controller would be updated to the Paging_Grid in the View:

<%=Html.Grid("Paging_Grid", "GridModel",
column =>
{
column.Add(p => p.Id).HeaderText("Id");
column.Add(p => p.QIec).HeaderText("QIec");
})
%>

But, the data is just shown (as plain data). No DOM renedering is done.

Any Ideas examples about that? (I tryied that with partial views, but still did not succeed)

Thx.

Balaji M [Syncfusion]
Replied On October 30, 2009 01:19 AM UTC

Hi lukasz,

We regret for the delayed response.

We regret to let you know that currently, we don't support update a grid by another form. We can achive the filtering a grid by using partial view. I have created a simple sample to this issue.


Refer the below code snippet, which illustrates this.
[View]
<%--include sfUtility script into application --%>
<%Html.RegisterScript(CommonScripts.sfUtility); %>
<%using (Ajax.BeginForm("Index",new AjaxOptions(){UpdateTargetId="UpdatePanel",OnSuccess="hidePopup"}))
{%>

select Category :<%=Html.DropDownList("Category",new[]
{
new SelectListItem{Text="Beverages",Value="1"},
new SelectListItem{Text="Condiments",Value="2"},
new SelectListItem{Text="Confections",Value="3"},
new SelectListItem{Text="Dairy Products",Value="4"},
new SelectListItem{Text="Grains/Cereals",Value="5"},
new SelectListItem{Text="Meat/Poultry",Value="6"},
new SelectListItem{Text="Produce",Value="7"},
new SelectListItem{Text="Seafood",Value="8"},
},"Choose Category") %>




<%}%>


<%Html.RenderPartial("GridUserControl", ViewData); %>




[Controller]
public ActionResult Index(int? Category)
{
int? categoryID = Category==null?0:Category;
IEnumerable data = new NorthwindDBDataContext().Products.Where(c => c.CategoryID ==

categoryID).ToList();
GridPropertiesModel model = new GridPropertiesModel
{
DataSource = data,
AutoFormat = Syncfusion.Mvc.Shared.Skins.Office2007Silver,
AllowSorting = true,
AllowPaging = true,
PageCount = 5,
PageSize = 10,
PagingSortingMapper = "PagingAction?CategoryID=" + categoryID.ToString(),
Caption = "Product List"
};
ViewData["GridModel"] = model;
if (IsAjaxCall())
return PartialView("GridUserControl",this.ViewData);
else
return View();
}

private bool IsAjaxCall()
{
return ControllerContext.HttpContext.Request.Headers["X-Requested-With"] == "XMLHttpRequest";
}

[AcceptVerbs(HttpVerbs.Post)]
public ActionResult PagingAction(PagingParams args, int CategoryID)
{
IEnumerable data = new NorthwindDBDataContext().Products.Where(c => c.CategoryID ==

CategoryID).ToList();
return data.GridActions();
}


The sample illustrates,

1. Grid is placed inside the Partial view.
2. Index actionresult contains the Category(ie. query_params)
3. Intially grid renders null,because of Category is null
4. Select the any category from dropDownlist,the target category product list is loaded in grid.

Please refer the sample from the below location,
http://files.syncfusion.com/support//grid_mvc/Incidents/F90846/Mvc_SampleGrid

Please let me know if you have any concerns.

Regards,
M. Balaji.

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.

Warning Icon 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.Close Icon

;