PDA

View Full Version : [CLOSED] Store records not available in client side after Grid bind in server side using Page Proxy



speedstepmem4
Feb 04, 2015, 10:15 AM
Hi Team,

In the code sample provided below, we are using PageProxy to bind the grid data to the store using OnReadData server side.
Immediately after binding the data to the grid store we need to access that store items in client side. Hence we are using the


ResourceManager1.AddScript("SelectRow();");

for manipulation.

But we are not able to retrieve the records client side after loading data to the store sever side.




App.Store1.data.items;
returns empty



Note: In GridPanel the added items are displayed!!!

.aspx page


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="SSTM.WebApp.WebForm1" %>

<!DOCTYPE html>

<html>
<head id="Head1" runat="server">
<title>PageProxy with DirectMethod - Ext.NET Examples</title>
<link href="/resources/css/examples.css" rel="stylesheet" />
</head>
<body>
<form id="Form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" Namespace="App" />

<h1>PageProxy with DirectMethod</h1>

<ext:GridPanel
ID="GridPanel1"
runat="server"
Title="Array Grid"
Width="700"
Height="310">
<Store>
<ext:Store ID="Store1" runat="server" OnReadData="Store1_ReadData">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="company" />
<ext:ModelField Name="price" Type="Float" />
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:PageProxy>
</ext:PageProxy>
</Proxy>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" Width="35" />
<ext:Column ID="Column1" runat="server" Text="Company" DataIndex="company" Flex="1" />
<ext:Column ID="Column2" runat="server" Text="Price" Width="75" DataIndex="price">
<Renderer Format="UsMoney" />
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</form>
<script>
function SelectRow() {
var test = App.Store1.data.items;
}
</script>
</body>
</html>


.cs page:


using Ext.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SSTM.WebApp
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}

protected void Store1_ReadData(object sender, StoreReadDataEventArgs e)
{
BindStore();
ResourceManager1.AddScript("SelectRow();");
}

private void BindStore()
{
this.Store1.DataSource = new List<object>
{
new { company = "3m Co", price = 71.72},
new { company = "speed step", price = 81.82}
};

this.Store1.DataBind();
}
}
}



Guide us to a solution!!!

fabricio.murta
Feb 04, 2015, 4:57 PM
Hi @speedstepmem4,

Is it a solution for you to call SelectedRow() on the EndUpdate event?

If you remove your ResourceManager1.AddScript() from code behind and put, inside the ext:Store tag the following markup:


<Listeners>
<EndUpdate Handler="SelectRow();" />
</Listeners>


It will run your javascript function when data is already on place. The point here is to call the javascript function after the data is actually updated into the store, right?

Let me know if this does not help you with your issue.

speedstepmem4
Feb 05, 2015, 4:01 AM
Hi fabricio.murta

Thanks for the guidance. Now we can retrieve the data in the store.
Please mark this as closed!!