[CLOSED] Bind System.IO To Store + GridPanel

  1. #1

    [CLOSED] Bind System.IO To Store + GridPanel

    Hello I would like to if Store supports System.IO to bind Files.

    
        <Coolite:GridPanel ID="GridPanel1" StoreID="dtaUploadFile" StripeRows="true" Collapsible="true" runat="server">
            <ColumnModel ID="ColumnModel3" runat="server">
                <Columns>
                    <Coolite:Column Header="File Name" DataIndex="Name" Sortable="true">
                    </Coolite:Column>
                </Columns>
            </ColumnModel>
        </Coolite:GridPanel>
    
        <Coolite:Store ID="Store1" runat="server">
            <Reader>
                <Coolite:JsonReader>
                    <Fields>
                        <Coolite:RecordField Name="Name" Type="Auto" />
                    </Fields>
                </Coolite:JsonReader>
            </Reader>
        </Coolite:Store>
    Codebehind.cs

        protected void dtaUploadFile_GetFiles()
        {
            System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(@"C:\Files");
    
            dtaUploadFile.DataSource = dir.GetFiles();
            dtaUploadFile.DataBind();
        }
    When I do this i'm getting Store null. Can anyone help me

    Thank You..

  2. #2

    RE: [CLOSED] Bind System.IO To Store + GridPanel

    Hi Zarzand,

    There are a couple issues:

    1. In the GridPanel, you set the StoreID property to "dtaUploadFile", but should be set to "Store1".
    2. The <ext:Store> must be added to the controls collection before the <ext:GridPanel>, just move the Store above the GridPanel and it should work.
    3. The GridPanel must be given a height dimension.

    The following code sample demonstrates how to hook this all together.

    Example (code-behind)

    <script runat="server">
        protected void Page_Load(object sender, EventArgs e)
        {
            this.Store1.DataSource = new System.IO.DirectoryInfo(@"C:\").GetFiles();
            this.Store1.DataBind();
        }
    </script>
    Example (markup)

    <ext:Store ID="Store1" runat="server">
        <Reader>
            <ext:JsonReader>
                <Fields>
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    
    <ext:GridPanel 
        ID="GridPanel1" 
        runat="server" 
        StoreID="Store1" 
        Title="Files"
        Icon="DiskMultiple"
        StripeRows="true" 
        Collapsible="true" 
        Height="300"
        AutoExpandColumn="Name">
        <ColumnModel runat="server">
            <Columns>
                <ext:Column Header="File Name" ColumnID="Name" DataIndex="Name" />
            </Columns>
        </ColumnModel>
    </ext:GridPanel>
    I think this is a very cool example and demonstrates how powerful the Store+GridPanel combination can be. By just retrieving a list of files, we can bind and display in the a GridPanel and have full client-side paging, sorting and filtering. It's really not going to get much easier than that.

    Hope this helps.

    Geoffrey McGill
    Founder
  3. #3

    RE: [CLOSED] Bind System.IO To Store + GridPanel

    Thanks you very much Geoffre it work great
  4. #4

    RE: [CLOSED] Bind System.IO To Store + GridPanel

    This is pretty fricken awesome. Maybe it should be added to the Examples Explorer...?


Similar Threads

  1. Replies: 1
    Last Post: Jun 12, 2012, 10:34 AM
  2. Replies: 0
    Last Post: Mar 04, 2011, 12:05 PM
  3. Replies: 4
    Last Post: Feb 01, 2011, 11:54 AM
  4. Replies: 2
    Last Post: Aug 31, 2009, 6:03 PM
  5. Replies: 1
    Last Post: Jul 30, 2009, 10:32 AM

Posting Permissions