Dynamic Store/Grid...see headers, right row count, no data...

  1. #1

    Dynamic Store/Grid...see headers, right row count, no data...

    I have a combobox on a page that will return different datasets based on the selection.
    I'm trying to dynamically create the columns in the store and grid to display results..

    Oddly, I can see the columns, headers etc in the grid..and the grid has the right amount of rows, but I'm not seeing any data!! See attached... I'm sure I'm close!!!!


    Here is the store and grid definition:
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:WarehouseConnectionString %>" SelectCommand="Select ExcelDataId,DataType,Name FROM ExcelData ORDER BY NAME"></asp:SqlDataSource>
       
        <ext:ScriptManager ID="ScriptManager1" runat="server">
        </ext:ScriptManager>
        <ext:Hidden runat="server" id="hidDataType" />
        <ext:Store ID="storeDataType" runat="server" DataSourceId="SqlDataSource1">
            <Reader>
                <ext:JsonReader ReaderID="ExcelDataId">
                    <Fields>
                        <ext:RecordField Name="DataType" Type="String" />
                        <ext:RecordField Name="Name" Type="String" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Store id="Store1" runat="server" autoload="false" AutoDataBind="true" OnSubmitData="Store1_Submit1">
            <AjaxEventConfig isupload="true" />
            <Reader>
                <ext:JsonReader>
                    <Fields>
                        <ext:RecordField Name="FundId" Type="Int" />
                    </Fields>
                </ext:JsonReader>
            </Reader>
        </ext:Store>
        <ext:Panel runat="server" id="pnlExcel">
        <Body>
        <ext:ComboBox runat="server"  id="cmboDataType" StoreID="storeDataType" ValueField="DataType" DisplayField="Name">
                <AjaxEvents>
                <Select onevent="GetData">  
                <ExtraParams>
                <ext:Parameter Name="datatype" Value="#{cmboDataType}.getValue()" Mode="Raw" />
                </ExtraParams>
                </Select>
                </AjaxEvents>
        </ext:ComboBox>   
         </Body>
        </ext:Panel>
        <ext:GridPanel id="GridPanel1" striperows="true" AutoDataBind="true"    Title="No Report" header="false" trackmouseover="true" runat="server" storeid="Store1" autowidth="true" height="650">
            <SaveMask showmask="false" />
            <LoadMask showmask="true" msg="Fetching Data...." />
            <ColumnModel id="ColumnModel1" runat="server">
                <Columns>
                </Columns>
            </ColumnModel>
            <View>
                <ext:GroupingView ID="GroupingView1" HideGroupedColumn="true" EmptyGroupText="No Groups" EnableGroupingMenu="true" runat="server" ForceFit="true" StartCollapsed="true" GroupTextTpl='{text} ({[values.rs.length]} {[values.rs.length > 1 ? "Items" : "Item"]})' EnableRowBody="true">
    <GetRowClass Handler="" FormatHandler="False"></GetRowClass>
                </ext:GroupingView>
            </View>
            <BottomBar>
                <ext:PagingToolbar ID="PagingToolBar1" runat="server" StoreID="Store1" PageSize="50" DisplayInfo="true" DisplayMsg="Displaying Results {0} - {1} of {2}">
                    <Items>
                        <ext:ToolbarButton ID="btnToggleGroups" runat="server" Text="Expand/Collapse Groups" Icon="TableSort" Style="margin-left: 6px;" AutoPostBack="false">
                            <Listeners>
                                <Click Handler="#{GridPanel1}.getView().toggleAllGroups();" />
                            </Listeners>
                        </ext:ToolbarButton>
                        <ext:Button ID="Button3" runat="server" Text="To Excel" Icon="PageExcel">
                            <Listeners>
                                <Click Handler="submitValue(#{GridPanel1}, #{FormatType}, 'xls');" />
                            </Listeners>
                        </ext:Button>
                    </Items>
                </ext:PagingToolbar>
            </BottomBar>
         
        </ext:GridPanel>



    Here is the server side method:
       public void GetData(object sender, AjaxEventArgs e)
            {
    
                string dataType = e.ExtraParams["datatype"];
                DataSet ds = SPs.ExcelData(dataType).GetDataSet();
    
                //clear out the fields in the current store.
                this.Store1.RemoveFields();
                foreach (DataColumn c in ds.Tables[0].Columns)
                {
                    this.Store1.Reader.Reader.Fields.Add(new RecordField(c.ColumnName));
                } 
                Column col = null; 
                this.GridPanel1.ColumnModel.Columns.Clear();
                foreach (DataColumn c in ds.Tables[0].Columns)
                {
                    col = new Column();
                    col.ColumnID = c.ColumnName;
                    col.Header = c.ColumnName;
                    col.Sortable = true;
                    col.DataIndex = c.ColumnName;
    
                    this.GridPanel1.ColumnModel.Columns.Add(col);
                }
                this.GridPanel1.Reconfigure();
                this.Store1.DataSource = ds;
                this.Store1.DataBind(); 
                this.GridPanel1.DataBind(); 
            }
  2. #2

    RE: Dynamic Store/Grid...see headers, right row count, no data...

    I figured it out..


    this.Store1.AddField(new RecordField(c.ColumnName, RecordFieldType.Auto));
    // this.Store1.Reader.Reader.Fields.Add(new RecordField(c.ColumnName,RecordFieldType.Auto ));



Similar Threads

  1. GridPanel showing data return Store.Count value 0
    By abhi_sheklohiya in forum 1.x Help
    Replies: 3
    Last Post: Mar 26, 2012, 7:06 PM
  2. Replies: 1
    Last Post: Mar 08, 2012, 2:52 PM
  3. Replies: 2
    Last Post: Feb 10, 2011, 6:43 PM
  4. Replies: 1
    Last Post: Nov 25, 2009, 9:09 AM
  5. Dynamic Store/Grid Load on Postback - no data.
    By rthiney in forum 1.x Help
    Replies: 4
    Last Post: Aug 12, 2009, 7:38 AM

Posting Permissions