[CLOSED] Problem for load GridPanel with code behind

  1. #1

    [CLOSED] Problem for load GridPanel with code behind

    Hi,

    I create a gridpanel with button for add row. This row is add with a function in script.

           var addElemento = function () {
                    var grid = #{GridPanelComposicao};
                    grid.editingPlugin.cancelEdit();
    
                    // Create a record instance through the ModelManager
                    var r = Ext.ModelManager.create({
                        id_campo: '0',
                        tipo_campo: '0',
                        nome: 'N/D',
                        tipo_dado: 'N/D',
                    }, 'ModelElemento');
    
                    grid.store.insert(0, r);
                    grid.editingPlugin.startEdit(0, 0);
                };
    Click image for larger version. 

Name:	01.PNG 
Views:	35 
Size:	9.3 KB 
ID:	6074

    Its ok, but when i load this grid in code behind, this not found. For work i have first click in button that call addElemento function and later call my function in code behind for load this grid, then this work.

    for load the grid in code behind i use the code:

    foreach (ComposicaoMetodoInfo item in metodoControl.ObterComposicaoMetodoPorId(id_metodo))
                {
                    StoreGridComposicao.Add
                    (new
                    {
                        id_campo = "0",//item.id_campo.ToString(),
                        tipo_campo = "0", //item.tipo.id_tipo_metadado.ToString(),
                        nome = item.nome,
                        tipo_dado = item.tipo.id_tipo_metadado.ToString()
                    });
                }
    I belive i have initialize a component, but i dont know.

    My grid:

    <ext:GridPanel ID="GridPanelComposicao" 
                                           runat="server"
                                           Width="500"
                                           Height="200" 
                                           Frame="true" Margin="10"
                                           Title="Elementos Cadastrados">
                                <Store>
                                    <ext:Store ID="StoreGridComposicao" runat="server">
                                        <Sorters>
                                            <ext:DataSorter Property="start" Direction="ASC" />
                                        </Sorters>
                                        <Model>
                                            <ext:Model ID="ModelElemento" runat="server" Name="ModelElemento">
                                                <Fields>
                                                    <ext:ModelField Name="id_campo" Mapping="id_campo" Type="String" />
                                                    <ext:ModelField Name="tipo_campo" Mapping="tipo_campo" Type="String" />
                                                    <ext:ModelField Name="nome" Mapping="nome" Type="String" />
                                                    <ext:ModelField Name="tipo_dado" Mapping="tipo_dado" Type="String" />
                                                </Fields>
                                            </ext:Model>
                                        </Model>
                                    </ext:Store>
                                </Store>
                                <Plugins>
                                    <ext:RowEditing ID="RowEditingElemento" runat="server" ClicksToMoveEditor="1" AutoCancel="false" SaveHandler="validateSaveElemento" />
                                </Plugins>            
                                <TopBar>
                                    <ext:Toolbar ID="ToolbarElementos" runat="server">
                                        <Items>
                                            <ext:Button ID="btnAddElemento" runat="server" Text="Adicionar Elemento" Icon="Add">
                                                <Listeners>
                                                    <Click Fn="addElemento" />
                                                </Listeners>
                                            </ext:Button>
                                            <ext:Button ID="btnRemoveElemento" runat="server" Text="Remover Elemento" Icon="Delete" Disabled="true">
                                                <Listeners>
                                                    <Click Fn="removeElemento" />
                                                </Listeners>
                                            </ext:Button>
                                        </Items>
                                    </ext:Toolbar>
                                </TopBar>            
                                <ColumnModel>
                                    <Columns>
                                        <ext:RowNumbererColumn ID="RowNumbererColumnID" runat="server" Width="25" />
                                    
                                        <ext:Column ID="Col02" runat="server" Text="ID" DataIndex="id_campo" Width="40" Visible="false" />
    
                                        <ext:Column ID="Col04" runat="server" Text="Nome" DataIndex="nome" Width="150">
                                            <Editor>
                                                <ext:TextField ID="TextFieldNome" runat="server" AllowBlank="false" Width="150" />
                                            </Editor>
                                        </ext:Column>
                                        <ext:Column ID="Col05" runat="server" Text="Tipo Dado" DataIndex="tipo_dado" Width="100">
                                            <Renderer Fn="ConvertValueToText" />
                                            <Editor>
                                                <ext:ComboBox ID="cboTiposDado" 
                                                              runat="server" 
                                                              EmptyText="Selecione..." 
                                                              Editable="false" width="100">
                                                    <Items>
                                                        <ext:ListItem Text="Direto" Value="1" />
                                                        <ext:ListItem Text="Lista"  Value="2" />
                                                        <ext:ListItem Text="Matriz" Value="3" />
                                                    </Items>
                                                 </ext:ComboBox>
                                            </Editor>
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                                <Listeners>
                                    <SelectionChange Handler="#{btnRemoveElemento}.setDisabled(!selected.length);" />
                                </Listeners>
                            </ext:GridPanel>
    Someone can help me please?

    Thanks
    Last edited by Daniil; Apr 25, 2013 at 4:05 AM. Reason: [CLOSED]
  2. #2
    Hi @vnmacedo,

    I do not understand the following points.

    Quote Originally Posted by vnmacedo View Post
    Its ok, but when i load this grid in code behind, this not found.
    Not found? Please clarify.

    Quote Originally Posted by vnmacedo View Post
    for load the grid in code behind i use the code:

    foreach (ComposicaoMetodoInfo item in metodoControl.ObterComposicaoMetodoPorId(id_metodo))
                {
                    StoreGridComposicao.Add
                    (new
                    {
                        id_campo = "0",//item.id_campo.ToString(),
                        tipo_campo = "0", //item.tipo.id_tipo_metadado.ToString(),
                        nome = item.nome,
                        tipo_dado = item.tipo.id_tipo_metadado.ToString()
                    });
                }
    Not sure what this code snippet means. Do you bind data to a grid here?

    A full runnable sample to reproduce the problem would be appreciated.

Similar Threads

  1. Replies: 5
    Last Post: Jul 15, 2013, 10:13 AM
  2. [CLOSED] Load Mask in code behind
    By bayoglu in forum 2.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 07, 2013, 11:42 PM
  3. Replies: 1
    Last Post: Jul 07, 2011, 8:34 PM
  4. Load mask from code behind
    By maephisto in forum 1.x Help
    Replies: 11
    Last Post: Apr 13, 2011, 2:33 PM
  5. Replies: 0
    Last Post: Aug 17, 2010, 5:20 PM

Tags for this Thread

Posting Permissions