[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
Code:
<%@ 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>
RE: [CLOSED] Binding Store to Datatable VERY slow...
Hi,
It is no difference using SqlDataSource or bind grid with data directly (without DataSource control). The binding performs on client side therefore doesn't mater what source because data serialized to json object.
I noticed that you use CommandColumn. CommandColumn is heavy control because it creates toolbar for each row therefore data rendering can be long for 100 rows if you use CommandColumn.*
I recommend using it for a table with the number of lines of no more than 20.
Otherwise use ImageCommandColumn -*a simpler and faster version of CommanColumn
RE: [CLOSED] Binding Store to Datatable VERY slow...
Can you post a quick example of the image command column? I don't see where to set the image or the command name... Thanks
RE: [CLOSED] Binding Store to Datatable VERY slow...
Hi,
Please see example in SVN*
Coolite.Examples\Examples\GridPanel\Commands\Image _Command\*
RE: [CLOSED] Binding Store to Datatable VERY slow...
Thanks, please mark as [CLOSED]...
Alternative for MenuCommand but faster, not ImageCommand
Hi,
I use MenuCommand in my BufferView.
Still, rendering is slow. I read the MenuCommand is heavy control and you propose to use ImageColumn.
However, I have a lot of Command inside the menu, and converting them to image, will take 50% with of my grid.
Will you improve performance rendering of MenuCommand ?
Thks,
Jerome