PDA

View Full Version : [CLOSED] Trigger does not update the grid



ucaneto
May 28, 2014, 7:46 PM
I made a Trigger where you do a search in the database, I have done the debug and the bank only has oos filtered records, plus the grid does not update.



<ext:Toolbar ID="ToolbarAtividade" runat="server" AutoWidth="true">
<Items>
<ext:Button ID="btnIncluir" runat="server" Text="Incluir Novo" Icon="UserAdd" ToolTip="Cadastrar Novo" OnDirectClick="btnIncluir_Click">
</ext:Button>
<ext:ToolbarFill />
<ext:TriggerField
runat="server"
Width="400"
ID="Procurar"
FieldLabel="Procurar"
LabelWidth="50">
<Triggers>
<ext:FieldTrigger Icon="Clear" HideTrigger="true" />
<ext:FieldTrigger Icon="Search" />
</Triggers>
<DirectEvents>
<TriggerClick onevent="showTestWindow" />
</DirectEvents>
</ext:TriggerField>
</Items>
</ext:Toolbar>


code in C#



[DirectMethod]
protected void showTestWindow(object sender, DirectEventArgs e)
{
AtualizarGrid(Procurar.Text, null);
}

protected void AtualizarGrid(object sender, StoreReadDataEventArgs e)
{
TipoimovelCollection entitycol = new TipoimovelCollection();
entitycol.Query.OrderBy(entitycol.Query.Descricao. Ascending);
if (sender != null) entitycol.Query.Where(entitycol.Query.Descricao.Li ke("%"+sender+"%"));
entitycol.Query.Load();

var data = entitycol;
var store1 = this.GridPanel1.GetStore();

store1.DataSource = data;
store1.DataBind();


}

Daniil
May 29, 2014, 5:52 AM
Hi @ucaneto,

Please post the Store's configuration. I guess you use a PageProxy, don't you?

ucaneto
May 29, 2014, 5:00 PM
Hi @ucaneto,

Please post the Store's configuration. I guess you use a PageProxy, don't you?

The full Code is



<ext:Window
runat="server"
Plain="true"
Layout="Fit"
Width="730"
Height="375"
Closable="false"
ID="windowGrid"
Border="false"
Header="false">
<Items>

<ext:GridPanel
runat="server"
Border="false"
Title="Cadastro de Tipo de Im?vel"
ID="GridPanel1"
Scroll="Vertical">
<TopBar>
<ext:Toolbar ID="ToolbarAtividade" runat="server" AutoWidth="true">
<Items>
<ext:Button ID="btnIncluir" runat="server" Text="Incluir Novo" Icon="UserAdd" ToolTip="Cadastrar Novo" OnDirectClick="btnIncluir_Click">
</ext:Button>
<ext:ToolbarFill />
<ext:TriggerField
runat="server"
Width="400"
ID="Procurar"
FieldLabel="Procurar"
LabelWidth="50">
<Triggers>
<ext:FieldTrigger Icon="Clear" HideTrigger="true" />
<ext:FieldTrigger Icon="Search" />
</Triggers>
<DirectEvents>
<TriggerClick onevent="showTestWindow" />
</DirectEvents>
</ext:TriggerField>
</Items>
</ext:Toolbar>
</TopBar>

<Store>
<ext:Store ID="StoreImob" runat="server" OnReadData="AtualizarGrid" PageSize="7">
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="IdTipoImovel" Mapping="IdTipoImovel" Type="String" />
<ext:ModelField Name="Descricao" Mapping="Descricao" Type="String" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>

<ColumnModel>
<Columns>

<ext:Column ID="Id" runat="server" Text="Codigo" DataIndex="IdTipoImovel" Filterable="false" Flex="4" />
<ext:Column ID="Nome" runat="server" Text="Descri??o" DataIndex="Descricao" Flex="19" />
<ext:CommandColumn ID="CommandColumn1" runat="server" Width="35">

<Commands>
<ext:GridCommand Icon="NoteEdit" CommandName="Edit">
<ToolTip Text="Editar Registro" />
</ext:GridCommand>
</Commands>

<DirectEvents>
<Command OnEvent="btnAlterar_Click">
<EventMask ShowMask="true" Msg="Aguarde Carregando..." />
<ExtraParams>
<ext:Parameter Value="record.data.IdTipoImovel" Mode="Raw" Name="IdSelecionadoGrid"></ext:Parameter>
<ext:Parameter Value="record.data.Descricao" Mode="Raw" Name="NomeSelecionadoGrid"></ext:Parameter>
</ExtraParams>
</Command>
</DirectEvents>

</ext:CommandColumn>

</Columns>
</ColumnModel>

<Features>
<ext:GridFilters runat="server" ID="GridFilters1" Local="true">
<Filters>
<ext:NumericFilter DataIndex="Id" />
<ext:StringFilter DataIndex="Nome" />
</Filters>
</ext:GridFilters>
</Features>

<SelectionModel>
<ext:RowSelectionModel ID="RowSelectionModel1" runat="server" Mode="Single" />
</SelectionModel>

<BottomBar>

<ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" EmptyMsg="Sem Registro Encontrado">
<Items>

<ext:Label ID="lblPageSize" runat="server" Text="Registros por p?gina:" />

<ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />

<ext:ComboBox ID="cboPageSize" runat="server" Width="80">

<Items>
<ext:ListItem Text="1" />
<ext:ListItem Text="7" />
<ext:ListItem Text="15" />
<ext:ListItem Text="20" />
<ext:ListItem Text="100" />
</Items>

<SelectedItems>
<ext:ListItem Value="7" />
</SelectedItems>

<Listeners>
<Select Handler="#{GridPanel1}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanel1}.store.reload();" />
</Listeners>

</ext:ComboBox>

</Items>
</ext:PagingToolbar>

</BottomBar>

</ext:GridPanel>

</Items>
</ext:Window>

Daniil
May 30, 2014, 5:43 AM
Thanks. Unfortunately, it didn't help me to reproduce the problem.

Please provide a full test case, see Example (Very Helpful) here:
Forum Guidelines For Posting New Topics (http://forums.ext.net/showthread.php?3440)

It should not depend on a database. Please use some inline test data instead.