GridPanel with DataSet, where am I wrong?

  1. #1

    GridPanel with DataSet, where am I wrong?

    This is the first time you use Ext.Net. Based on the examples, I tried to mount a GridPanel, but am not having success. Where is the mistake?
    <asp:WizardStep ID="wSelWorkshops" runat="server" StepType="Step" 
                        Title="Selecionar Workshops">
                        <ext:ResourceManager ID="ResourceManager1" runat="server" />
                        <ext:Store ID="Store1" runat="server">
                            <Reader>
                                <ext:JsonReader>
                                    <Fields>
                                        <ext:RecordField Name="ID" />
                                        <ext:RecordField Name="Data" />
                                        <ext:RecordField Name="Inicio" />
                                        <ext:RecordField Name="Fim" />
                                        <ext:RecordField Name="Atividade" />
                                        <ext:RecordField Name="Palestrante" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                        <ext:GridPanel 
                                ID="GridPanelWS"
                                runat="server"
                                StoreID="Store1"
                                StripeRows="true"
                                Title="Worskops"
                                Collapsible="true"
                                Width="550"
                                Height="350">
                                <ColumnModel runat="server">
                                    <Columns>
                                    <ext:Column runat="server" ColumnID="ID" Header="" DataIndex="idturma" MenuDisabled="true" Fixed="true" Resizable="false" Width="25"/>
                                    <ext:DateColumn runat="server" Width="75" DataIndex="inicio"  Header="Data" Format="dd/MM/yy"  />
                                    <ext:DateColumn runat="server" Width="50" DataIndex="horaini" Header="Inicio" Format="H:mm" />
                                    <ext:DateColumn runat="server" Width="50" DataIndex="horafim" Header="Inicio" Format="H:mm" />
                                    <ext:Column runat="server" ColumnID="etp_Etapa" Width="150" DataIndex="etp_Etapa" Header="Atividade" />
                                    <ext:Column runat="server" ColumnID="etp_Etapa" Width="150" DataIndex="Educador" Header="Palestrante" />
                                </Columns>
                            </ColumnModel>
                           <SelectionModel>
                           <ext:CheckboxSelectionModel runat="server" />
                           </SelectionModel>
                           <Buttons>
                           <ext:Button ID="btnWS" runat="server" Text="Prosseguir" Visible="false">
                           <DirectEvents>
                                <Click OnEvent="bntWS_Click">
                                    <EventMask ShowMask="true" />
                                </Click>
                           </DirectEvents>
                           </ext:Button>
                           </Buttons>
                        </ext:GridPanel>
                    </asp:WizardStep>
    code behind
     protected void CarregarWS(int id) {
                
                ClassBS bs = new ClassBS();
                DataTable dt;
                dt = bs.CarregarWorkshop(id);
    
                Ext.Net.Store st = new Ext.Net.Store();
                Store1.DataSource = dt;
                Store1.DataBind();
                try
                {
                    if (dt != null)
                    {
                        
                        this.GridPanelWS.DataBind();
    
    
    
                    }
                }
                catch (Exception exp)
                {
                    DisplayAJAXMessage(this, exp.Message);
    
                }
            
            }
  2. #2
    Hi,

    Welcome!

    There might be other issues, but one thing I noticed... the Columns .DataIndex value should be the same (case-sensitive) as the Stores RecordField .Name value.

    Example

    // Store
    <ext:RecordField Name="Inicio" />
    
    // GridPanel
    // Changed DataIndex="inicio" to DataIndex="Inicio"
    <ext:DateColumn runat="server" Width="75" DataIndex="Inicio" Header="Data" Format="dd/MM/yy" />
    As well, you shouldn't have to call .DataBind() on the GridPanel.

    Hope this helps.
    Geoffrey McGill
    Founder
  3. #3
    Thanks for the promptness and speed, saving my life!!

    one more doubt, I have a RadioButtonList that triggers the function that loads the grid, but I can not load the grid. Do I have to put the grid in a updatepanel?

    <ext:RecordField Name="idturma" />
    <ext:RecordField Name="inicio" />
    <ext:RecordField Name="horaini" />
    <ext:RecordField Name="horafim" />
    <ext:RecordField Name="etp_Etapa" />
    <ext:RecordField Name="Educador" />

    Quote Originally Posted by geoffrey.mcgill View Post
    Hi,

    Welcome!

    There might be other issues, but one thing I noticed... the Columns .DataIndex value should be the same (case-sensitive) as the Stores RecordField .Name value.

    Example

    // Store
    <ext:RecordField Name="Inicio" />
    
    // GridPanel
    // Changed DataIndex="inicio" to DataIndex="Inicio"
    <ext:DateColumn runat="server" Width="75" DataIndex="Inicio" Header="Data" Format="dd/MM/yy" />
    As well, you shouldn't have to call .DataBind() on the GridPanel.

    Hope this helps.
    Last edited by geoffrey.mcgill; Apr 05, 2012 at 11:57 PM. Reason: please use [CODE] tags
  4. #4
    Do I have to put the grid in a updatepanel?
    No. Please do not add an UpdatePanel to your Page. They are in no way required.

    Just set the data again, and rebind the Store. This can be done during any DirectEvent or DirectMethod.

    Example

    this.Store1.DataSource = this.Data;this.Store1.DataBind();
    Hope this helps.
    Geoffrey McGill
    Founder
  5. #5
    Resolved. Thank you.
    Now I want to group by event date. Follow the example:
    https://examples1.ext.net/ # / GridPanel / Miscellaneous / Grouping /
    But I'm doing something wrong again.



     <asp:WizardStep ID="wSelWorkshops" runat="server" StepType="Step" 
                        Title="Selecionar Workshops">
                        <ext:ResourceManager ID="ResourceManager1" runat="server" />
                        <ext:Store ID="Store1" runat="server">
                            <Reader>
                                <ext:JsonReader>
                                    <Fields>
                                        <ext:RecordField Name="idturma" />
                                        <ext:RecordField Name="inicio" />
                                        <ext:RecordField Name="horaini" />
                                        <ext:RecordField Name="horafim" />
                                        <ext:RecordField Name="etp_Etapa" />
                                        <ext:RecordField Name="Educador" />
                                    </Fields>
                                </ext:JsonReader>
                            </Reader>
                        </ext:Store>
                        <ext:GridPanel 
                                ID="GridPanelWS"
                                runat="server"
                                StoreID="Store1"
                                StripeRows="true"
                                Title="Worskops"
                                Collapsible="true"
                                AutoExpandColumn="inicio" 
                                Width="550"
                                Height="350"
                                Frame="true">
                                <ColumnModel runat="server">
                                    <Columns>
                                    <ext:Column runat="server" ColumnID="ID" Header="" DataIndex="idturma" MenuDisabled="true" Fixed="true" Resizable="false" Width="25"/>
                                    <ext:DateColumn runat="server" Width="75" DataIndex="inicio"  Header="Data" Format="dd/MM/yy"  />
                                    <ext:DateColumn runat="server" Width="50" DataIndex="horaini" Header="Inicio" Format="H:mm" />
                                    <ext:DateColumn runat="server" Width="50" DataIndex="horafim" Header="Inicio" Format="H:mm" />
                                    <ext:Column runat="server" ColumnID="etp_Etapa" Width="150" DataIndex="etp_Etapa" Header="Atividade" />
                                    <ext:Column runat="server" ColumnID="etp_Etapa" Width="150" DataIndex="Educador" Header="Palestrante" />
                                </Columns>
                            </ColumnModel>
                             <LoadMask ShowMask="true" />
                           <SelectionModel>
                           <ext:CheckboxSelectionModel runat="server" />
                           </SelectionModel>
                           <View>
                           <ext:GroupingView
                                ID="gvWS"
                                HideGroupedColumn="true"
                                runat="server" 
                                ForceFit="true"
                                StartCollapsed="false"
                                GroupTextTpl='<span id="inicio-{[values.rs[0].data.inicio]}></span>'
                                EnableRowBody="true">
                                <Listeners>
                                    <Refresh Fn="setGroupStyle" />
                                </Listeners>
                                 <GetRowClass Handler="var d = record.data; rowParams.body = String.format('<div style=\'padding:0 5px 5px 5px;\'>{0} [{1}]</div>', d.idturma,d.inicio,d.horaini,d.horafim,d.etp_Etapa,d.Educador);" />
                           </ext:GroupingView>
                           </View>
                           <Buttons>
                           <ext:Button ID="btnWS" runat="server" Text="Prosseguir" Visible="false">
                           <DirectEvents>
                                <Click OnEvent="bntWS_Click">
                                    <EventMask ShowMask="true" />
                                </Click>
                           </DirectEvents>
                           </ext:Button>
                           </Buttons>
                        </ext:GridPanel>
                    </asp:WizardStep>
    Quote Originally Posted by geoffrey.mcgill View Post
    No. Please do not add an UpdatePanel to your Page. They are in no way required.

    Just set the data again, and rebind the Store. This can be done during any DirectEvent or DirectMethod.

    Example

    this.Store1.DataSource = this.Data;this.Store1.DataBind();
    Hope this helps.

Similar Threads

  1. Replies: 3
    Last Post: Mar 19, 2013, 9:05 PM
  2. Replies: 2
    Last Post: Sep 27, 2011, 7:25 AM
  3. Replies: 3
    Last Post: Dec 20, 2010, 6:32 AM
  4. Replies: 2
    Last Post: Nov 17, 2009, 1:26 PM
  5. Replies: 1
    Last Post: Jan 29, 2009, 9:35 AM

Tags for this Thread

Posting Permissions