[CLOSED] Binding Store to Datatable VERY slow...

  1. #1

    [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


    
    <%@ 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 = " &amp; 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]
  2. #2

    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
  3. #3

    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
  4. #4

    RE: [CLOSED] Binding Store to Datatable VERY slow...

    Hi,

    Please see example in SVN*
    Coolite.Examples\Examples\GridPanel\Commands\Image _Command\*
  5. #5

    RE: [CLOSED] Binding Store to Datatable VERY slow...



    Thanks, please mark as [CLOSED]...

  6. #6

    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
  7. #7
    Hi,

    Are you sure that it is MenuCommand the performance issue? You use BufferView therefore it should be very slow. If you remove commands then performance much better?
  8. #8
    Hi,

    There is Shared property for Menu. In this case one instance of menu will be used for all rows. I reccomnd to use it if your menu the same for all rows. It can improve performance

Similar Threads

  1. Replies: 1
    Last Post: Jun 26, 2012, 1:40 PM
  2. Datatable and Store columns mapping
    By QualityCode in forum 1.x Help
    Replies: 0
    Last Post: Dec 16, 2010, 8:45 PM
  3. Creating Store from Datatable
    By QualityCode in forum 1.x Help
    Replies: 2
    Last Post: Dec 13, 2010, 5:20 AM
  4. Replies: 3
    Last Post: Nov 30, 2010, 11:07 AM
  5. Replies: 6
    Last Post: Dec 20, 2008, 4:35 AM

Posting Permissions