Apr 19, 2013, 12:35 PM
[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.
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:
My grid:
Thanks
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);
};
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]