PDA

View Full Version : JsonReader Problem



Casbah
Oct 17, 2008, 8:57 AM
Can I use JsonReader this way?

Resulted string 's' = { rowCount:48, list:[ {markID:3}, {markID:4}, ....] };

But no data is bound. If I remove root="list" property, than bound many empty rows.

What is wrong with this code.






<script runat="server">


protected void Store1_RefreshData(object sender, StoreRefreshDataEventArgs e)


{


ObStorage obStorage = new ObStorage();


ObRequest select = ObRequest.Select("autocatalog", "<searchable>");


ObRecordset rows = obStorage.Execute(select);


JsonObject root = new JsonObject();


root.Put("rowCount", rows.Count);





JsonArray list = new JsonArray(rows);


root.Put("list", list);


string s = JSON.Serialize(root);


Store1.DataSource = s;


Store1.DataBind();


}


protected void Page_Load(object sender, EventArgs e)


{


Store1_RefreshData(null, null);


}





</script>


</head>


<body>


<form id="form1" runat="server">


<ext:ScriptManager ID="ScriptManager1" runat="server" />





<ext:Store ID="Store1" runat="server"


OnRefreshData="Store1_RefreshData">



<Proxy>
<ext:DataSourceProxy/>
</Proxy>
<Reader>


<ext:JsonReader ReaderID="markID" TotalProperty="rowCount" Root="list">


<Fields>


<ext:RecordField Name="markID" Type="Int"/>


</Fields>


</ext:JsonReader>


</Reader>


</ext:Store>





<ext:GridPanel runat="server" ID="GridPanel1" Title="Employees" Frame="true" StoreID="Store1" Height="300">


<ColumnModel runat="server">


<Columns>


<ext:Column DataIndex="markID" Header="Title" Width="150" />


</Columns>


</ColumnModel>


<SelectionModel>


<ext:RowSelectionModel runat="server" />


</SelectionModel>


<BottomBar>


<ext:PagingToolBar ID="PagingToolBar1" runat="server" PageSize="3" StoreID="Store1"


DisplayInfo="true" DisplayMsg="Displaying employees {0} - {1} of {2}" EmptyMsg="No employees to display" />


</BottomBar>


<LoadMask ShowMask="true" />


</ext:GridPanel>


</form>


</body>


</html>