May 15, 2009, 12:43 PM
[CLOSED] Binding Store to Datatable VERY slow...
I am binding a store to a datatable that I have created in code-behind. The store uses a JsonReader, but it is very slow, it takes a few seconds to load the list of maybe 100 rows. And during the load, no load mask is showing either. This is much slower than binding the store to a sql data source... but I don't have that option here.
The column with the text loads first and then it takes a long time to load the command columns...
Is there a better way to bind the store to the datatable? Is there a way to show the loading mask?
Any suggestions would be appreciated... Thanks
The column with the text loads first and then it takes a long time to load the command columns...
Is there a better way to bind the store to the datatable? Is there a way to show the loading mask?
Any suggestions would be appreciated... Thanks
<%@ Page Language="vb"%>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<%@ Import Namespace="System.Configuration" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="Microsoft.ApplicationBlocks.Data" %>
<%@ Import Namespace="Helpers" %>
<%@ Import Namespace="Helpers.FormatHelpers" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head2" runat="server">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'load the navigation menu
If Not Page.IsPostBack Then
BuildNavBar()
End If
End Sub
</script>
<script runat="server">
Public Sub BuildNavBar()
Dim cs As String = Connection.ConnectionString(Request.ServerVariables("SERVER_NAME"))
Dim ds As DataSet = SqlHelper.ExecuteDataset(cs, "spNavBarGetItems")
Dim dtNavBar As DataTable = ds.Tables(0).Clone
Dim c As DataColumn = New DataColumn("Level", System.Type.GetType("System.Int32"))
dtNavBar.Columns.Add(c)
AddChildren(ds, dtNavBar, -1, 0)
Store1.DataSource = dtNavBar
Store1.DataBind()
End Sub
Public Sub AddChildren(ByVal ds As DataSet, ByRef dtNavBar As DataTable, ByVal ParentID As Integer, ByVal Level As Integer)
Dim drSiblings() As DataRow = ds.Tables(0).Select("ParentID = " & ParentID)
'we are on a new level
Level += 1
Dim dr As DataRow
For Each dr In drSiblings
Dim ID As Integer = dr("ID")
Dim PageTitle As String = dr("PageTitle")
'Dim SortOrder As Integer = dr("SortOrder")
Dim Visible As Boolean = dr("Visible")
Dim URL As String = dr("URL")
'add this page to the nav bar data table
Dim row As DataRow
row = dtNavBar.NewRow()
row("id") = ID
row("PageTitle") = PageTitle
row("URL") = URL
row("Visible") = Visible
row("Level") = Level
dtNavBar.Rows.Add(row)
AddChildren(ds, dtNavBar, ID, Level)
Next
End Sub
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" ScriptMode="Debug" InitScriptMode="Inline">
</ext:ScriptManager>
<ext:Store ID="Store1" runat="server">
<Reader>
<ext:JsonReader ReaderID="ID">
<Fields>
<ext:RecordField Name="ID" Type="Int"/>
<ext:RecordField Name="PageTitle" Type="String"/>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
<ext:ViewPort ID="ViewPort1" runat="server">
<Body>
<ext:GridPanel ID="GridPanelSortOrder" runat="server"
autoheight="true"
Border="false"
StoreID="Store1"
AnimCollapse="true"
Title="" >
<ColumnModel>
<Columns>
<ext:Column ColumnId="PageTitle" Align="Left" Header="PageTitle" DataIndex="PageTitle" Resizable="false" MenuDisabled="true" Width="440" />
<ext:CommandColumn ColumnID="Commands" Width="20">
<Commands>
<ext:GridCommand Icon="PageWhiteGet" CommandName="moveup" QTipText="Move Up"></ext:GridCommand>
<ext:GridCommand Icon="PageWhitePut" CommandName="movedown" QTipText="Move Down"></ext:GridCommand>
</Commands>
</ext:CommandColumn>
</Columns>
</ColumnModel>
<Listeners>
<Command Handler="handleCommand(command, record.data.ID);" />
</Listeners>
<LoadMask Msg="Loading Nav Bar..." ShowMask="true" />
</ext:GridPanel>
</Body>
</ext:ViewPort>
</form>
</body>
</html>
Last edited by Daniil; Nov 01, 2010 at 7:08 PM.
Reason: [CLOSED]