Dec 15, 2016, 2:27 AM
Refreshing GridPanel Remote Filtering
Hi,
I was using the example code in Remote Filtering use in the MVC Examples (4.1), particularly the GridPanel_Spreadsheet. I wanted to refresh the Grid ListFilter after saving it but couldn't find a solution.
I am using ViewBag to store the values in the Grid ListFilter. It is working if I return it as View but not in direct method. I'm just starting to learn MVC and pardon me if my question and method may sound dumb.
I need to refresh the ViewBag after clicking the SAVE button.
Here are the changes I made in the MVC sample:
In my Views: ===> Please refer to LINE 41 below
I was using the example code in Remote Filtering use in the MVC Examples (4.1), particularly the GridPanel_Spreadsheet. I wanted to refresh the Grid ListFilter after saving it but couldn't find a solution.
I am using ViewBag to store the values in the Grid ListFilter. It is working if I return it as View but not in direct method. I'm just starting to learn MVC and pardon me if my question and method may sound dumb.
I need to refresh the ViewBag after clicking the SAVE button.
Here are the changes I made in the MVC sample:
In my Views: ===> Please refer to LINE 41 below
@(X.GridPanel()
.ColumnLines(true)
.Height(400)
.Width(775)
.Title("Spreadsheet")
.Frame(true)
.Store(X.Store()
.ID("Store1")
.Model(X.Model()
.IDProperty("year")
.Fields("year", "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec")
)
.Reader(X.ArrayReader())
.DataSource(Model)
.ServerProxy(
X.AjaxProxy().Url(Url.Action("Reload"))
)
)
.SelectionModel(
X.SpreadsheetSelectionModel()
.ID("SpreadsheetSelectionModel1")
.ColumnSelect(true)
.CheckboxSelect(true)
.PruneRemoved(false)
.Extensible(SpreadsheetExtensible.Y)
)
.ColumnModel(
X.Column().Text("Year").DataIndex("year").Flex(1).MinWidth(70),
X.Column().Text("Jan").DataIndex("jan").Width(50),
X.Column().Text("Feb").DataIndex("feb").Width(50),
X.Column().Text("Mar").DataIndex("mar").Width(50),
X.Column().Text("Apr").DataIndex("apr").Width(50),
X.Column().Text("May").DataIndex("may").Width(50),
X.Column().Text("Jun").DataIndex("jun").Width(50),
X.Column().Text("Jul").DataIndex("jul").Width(50),
X.Column().Text("Aug").DataIndex("aug").Width(50),
X.Column().Text("Sep").DataIndex("sep").Width(50),
X.Column().Text("Oct").DataIndex("oct").Width(50),
X.Column().Text("Nov").DataIndex("nov").Width(50),
X.Column()
.Text("Dec").DataIndex("dec").Width(50).Filter(X.ListFilter().Options(@ViewBag.ProductList))
)
.ViewConfig(X.GridView().TrackOver(false))
.Tools(X.Tool()
.Type(ToolType.Refresh)
.ToolTip("Reload Data")
.Handler("App.Store1.reload();")
)
.TopBar(
X.Toolbar()
.Items(
X.Component().Html("Selectable:"),
X.Button()
.Text("Save")
.DirectEvents(de =>
{
de.Click.Url = Url.Action("SaveChanges");
}),
X.ToolbarFill(),
X.Component().ID("Status")
)
)
//.Listeners(events => events.SelectionChange.Fn = "onSelectionChange")
.Plugins(
X.Clipboard(),
X.SelectionReplicator(),
X.GridFilters()
)
)
In my Controller:using System.Web;
using System.Web.Mvc;
using Ext.Net.MVC.Examples.Areas.GridPanel_Spreadsheet.Models;
namespace Ext.Net.MVC.Examples.Areas.GridPanel_Spreadsheet.Controllers
{
public class OverviewController : Controller
{
public ActionResult Index()
{
//this is working
ViewBag.ProductList = "1,4,6";
return this.View(GridPanel_SpreadsheetOverviewModel.GetData());
}
public ActionResult Reload()
{
return this.Store(GridPanel_SpreadsheetOverviewModel.GetData());
}
public ActionResult SaveChanges(StoreDataHandler handler)
{
//this is NOT working, I need to refresh the value of the GridFilter after the SAVE button is clicked.
ViewBag.ProductList = "1,4,6,10";
return this.Direct();
}
}
}
Last edited by chickenjoy; Dec 21, 2016 at 12:14 AM.