Mar 08, 2012, 2:30 PM
Get dynamic data before data binds to store and grid
Hello everyone,
Is there a way to get my data before it's binded to the reader/store?
What I'm trying to do: I want to be able to intercept my data from a controller/web service and before its binded to the store/reader/grid, parse the DataTable and create my reader's fields and grid's column model. I can do this easily if I get the DataTable from ViewData[...]. But the data should really be coming from a controller that is executing my model (a report).
I am using ASP.net MVC.
Any help please?
Here is my grid:
Here is my controller:
Also - quick question - I would be able to bind my PivotReport object as a parameter to be sent to the Execute method above correct? From code behind/DirectMethod?
Is there a way to get my data before it's binded to the reader/store?
What I'm trying to do: I want to be able to intercept my data from a controller/web service and before its binded to the store/reader/grid, parse the DataTable and create my reader's fields and grid's column model. I can do this easily if I get the DataTable from ViewData[...]. But the data should really be coming from a controller that is executing my model (a report).
I am using ASP.net MVC.
Any help please?
Here is my grid:
<ext:GridPanel runat="server" ID="ResultsGrid" AutoScroll="true" Title="Results"
Region="Center" Margins="5 0 0 0">
<TopBar>
<ext:Toolbar ID="ResultsToolbar" runat="server" Height="27">
<Items>
<ext:ToolbarFill ID="ResultsToolbarFill" runat="server" />
<ext:Button ID="ResultsRefreshButton" runat="server" Text="Refresh" Icon="Reload">
<Listeners>
<Click Handler="alert('Not yet implemented');" />
</Listeners>
</ext:Button>
</Items>
</ext:Toolbar>
</TopBar>
<ColumnModel runat="server">
<Columns>
</Columns>
</ColumnModel>
<Store>
<ext:Store ID="ResultsStore" runat="server">
<Reader>
<ext:JsonReader>
</ext:JsonReader>
</Reader>
<Proxy>
<ext:HttpProxy Url="/Pivot/Execute/" Json="True" Method="GET" OnDataBinding="ConfigureResultsGrid"/>
</Proxy>
</ext:Store>
</Store>
</ext:GridPanel>
I've beent trying different events in different places (store/reader/proxy..etc...) Everything seems to fire after I get the data and its bound Here is my controller:
[HandleError]
public class PivotController : Controller
{
public string Index()
{
return "Default action.";
}
public ContentResult Execute(PivotReport id)
{
DataTable dataTable = new DataTable();
dataTable.Columns.Add("Temp");
dataTable.Rows.Add(new object[] {123});
return Content(JSON.Serialize(dataTable));
}
}
Also - quick question - I would be able to bind my PivotReport object as a parameter to be sent to the Execute method above correct? From code behind/DirectMethod?
Last edited by ckarcz; Mar 08, 2012 at 2:43 PM.
Reason: fixed controller results - no more 200 error