PDA

View Full Version : [CLOSED] Grid Panel with remote paging in User Control



luiz
Mar 26, 2014, 1:35 AM
Hi,

I am using this (http://examples2.ext.net/#/GridPanel/Paging_and_Sorting/DirectMethod/) example, but with user control.

Please, see:

[DirectMethodProxyID(IDMode = DirectMethodProxyIDMode.Alias, Alias = "UC")]
class ...


[DirectMethod]
public object CarregarStore(string action, Dictionary<string, object> extraParams)
{
int total = 0;
List<Usuario> usuarios = null;

try
{
StoreRequestParameters parametros = new StoreRequestParameters(extraParams);

using (usuarioNegocio = new UsuarioNegocio())
{
usuarios = usuarioNegocio.ObterUsuarios(this.UsuarioLogado.Id , this.UsuarioLogado.Id_Clube, TipoUsuario, parametros.Start, parametros.Limit, out total).ToList<Usuario>();

return new { usuarios, total };
}
}
catch (Exception ex)
{
throw ex;
}
}



HTML

<ext:TabPanel ID="TabPanelUsuario" runat="server" AutoScroll="true" Plain="true" AnimCollapse="false">
<Plugins>
<ext:TabMenu ID="TabMenuPanelUsuario" runat="server" />
</Plugins>
<Items>
<ext:Panel ID="PanelListaUsuario" runat="server" Layout="FormLayout">
<Items>
<ext:GridPanel ID="GridPanelUsuario" runat="server" Height="400">
<Store>
<ext:Store ID="StoreUsuario" runat="server" PageSize="30" >
<Proxy>
<ext:PageProxy DirectFn="App.direct.UC.CarregarStore" />
</Proxy>
<Model>
<ext:Model ID="ModelUsuario" runat="server">
<Fields>
<ext:ModelField Name="Id" Type="int" />
<ext:ModelField Name="Nome" Type="String" />
<ext:ModelField Name="Login" Type="String" />
<ext:ModelField Name="Email" Type="String" />
<ext:ModelField Name="DataNascimento" Type="Date" />
<ext:ModelField Name="TelefoneFixo" Type="String" />
<ext:ModelField Name="TelefoneCelular" Type="String" />
<ext:ModelField Name="NomeMae" Type="String" />
<ext:ModelField Name="Sexo" Type="Boolean" />
<ext:ModelField Name="Clube" IsComplex="true" />
<ext:ModelField Name="Graduacao" IsComplex="true" />
<ext:ModelField Name="PagouAnuidade" Type="Boolean" />
<ext:ModelField Name="Ativo" Type="Boolean" />
<ext:ModelField Name="Rua" Type="String" />
<ext:ModelField Name="Cidade" IsComplex="true" />
<ext:ModelField Name="CEP" Type="String" />
<ext:ModelField Name="CPF" Type="String" />
<ext:ModelField Name="NumeroResidencia" Type="Int" />
<ext:ModelField Name="Bairro" Type="String" />
<ext:ModelField Name="Complemento" Type="String" />
<ext:ModelField Name="MaeResponsavel" Type="Boolean" />
<ext:ModelField Name="UsuarioPerfils" IsComplex="true" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModelUsuario" runat="server">
<Columns>
<ext:Column ID="ColumnNome" runat="server" Text="Nome" DataIndex="Nome" Flex="2" />
<ext:Column ID="ColumnSexo" runat="server" Text="Sexo" DataIndex="Sexo" Flex="1">
<Renderer Fn="RenderSexo" />
</ext:Column>
<ext:Column ID="ColumnLogin" runat="server" Text="Login" DataIndex="Login" Flex="2" />
<ext:Column ID="ColumnNomeMae" runat="server" Text="Nome da m?e" DataIndex="NomeMae" Flex="2" />
<ext:Column ID="ColumnVisivel" runat="server" Text="Ativo" DataIndex="Ativo" Flex="1">
<Renderer Fn="RenderAtivo" />
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:CheckboxSelectionModel ID="CheckboxSelectionModel" runat="server" Mode="Single">
<Listeners>
<Select Handler="#{BotaoRemoverUsuario}.enable(); #{BotaoEditarUsuario}.enable(); #{BotaoEditarUsuarioPrivilegios}.enable();" />
<Deselect Handler="if (!#{GridPanelUsuario}.selModel.hasSelection()) {
#{BotaoRemoverUsuario}.disable();
#{BotaoEditarUsuario}.disable();
#{BotaoEditarUsuarioPrivilegios}.disable();
}" />
</Listeners>
</ext:CheckboxSelectionModel>
</SelectionModel>
<Plugins>
<ext:RowExpander ID="RowExpanderGridUsuario" runat="server">
<Loader runat="server" Mode="Data" DirectMethod="#{DirectMethods}.ExibirDetalhesUsuario">
<LoadMask ShowMask="true" Msg="Aguarde..." />
<Params>
<ext:Parameter Name="data" Value="this.record.data.Id" Mode="Raw" />
</Params>
</Loader>
<Template ID="TemplateUsuario" runat="server">
<Html>
<div class="conteudoGrid">
<fieldset>
<legend>Informa??es da conta</legend>
<label>Login: {Login}</label> </br>
<label>Email: {Email}</label> </br>
<label>Gradua??o: {Graduacao.Nome}</label> </br>
<label>Clube: {Clube.Nome}</label> </br>
<label>Perfil:</label>
<ul>
<tpl for="UsuarioPerfils">
<li>{Perfil.Nome}</li>
</tpl>
</ul>

</fieldset>
<fieldset>
<legend>Informa??es pessoais</legend>
<label>Nome: {Nome} </label> </br>
<label>Nome da m?e: {NomeMae} </label> </br>
<tpl if="MaeResponsavel == 1">
<label>M?e respons?vel: Sim </label> </br>
<label>CPF da m?e: {CPF} </label> </br>
<tpl else>
<label>M?e respons?vel: N?o </label> </br>
<label>CPF do aluno: {CPF} </label> </br>
</tpl>
<label>RG: {RG} </label> </br>
<label>Telefone fixo: {TelefoneFixo} </label> </br>
<label>Telefone celular: {TelefoneCelular} </label>
</fieldset>
<fieldset>
<legend>Endere?o</legend>
<label>Rua: {Rua} </label> </br>
<label>Cidade: {Cidade.Nome} - {Cidade.Estado.Nome} </label> </br>
<label>CEP: {CEP} </label> </br>
<label>N?mero: {NumeroResidencia} </label> </br>
<label>Bairro: {Bairro} </label> </br>
<label>Complemento: {Complemento} </label>
</fieldset>
</div>
</Html>
</Template>
</ext:RowExpander>
</Plugins>
<View>
<ext:GridView ID="GridViewUsuario" runat="server" StripeRows="true">
</ext:GridView>
</View>
<TopBar>
<ext:Toolbar ID="ToolbarUsuario" runat="server">
<Items>
<ext:Button ID="BotaoEditarUsuario" runat="server" Text="Editar" Icon="ApplicationEdit" ToolTip="Editar um registro." Disabled="true">
<DirectEvents>
<Click OnEvent="BotaoEditarUsuario_Click">
<ExtraParams>
<ext:Parameter Name="data" Value="#{GridPanelUsuario}.getView().getSelectionModel(). getSelection()[0].data.Id" Mode="Raw" />
</ExtraParams>
<EventMask Msg="Carregando..." ShowMask="true" />
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="BotaoRemoverUsuario" runat="server" Text="Remover" IconCls="remover_16" ToolTip="Remover um registro." Disabled="true">
<DirectEvents>
<Click OnEvent="BotaoRemoverUsuario_Click">
<ExtraParams>
<ext:Parameter Name="data" Value="#{GridPanelUsuario}.getView().getSelectionModel(). getSelection()[0].data.Id" Mode="Raw" />
</ExtraParams>
<Confirmation Title="Confirma??o" ConfirmRequest="true" Message="Confirma a remo??o do registro?" />
<EventMask Msg="Carregando..." ShowMask="true" />
</Click>
</DirectEvents>
</ext:Button>
<ext:Button ID="BotaoEditarUsuarioPrivilegios" runat="server" Text="Gerenciar privil?gios" IconCls="privilegio_16" ToolTip="Editar um privilegios." Disabled="true">
<DirectEvents>
<Click OnEvent="BotaoEditarUsuarioPrivilegios_Click">
<ExtraParams>
<ext:Parameter Name="data" Value="#{GridPanelUsuario}.getView().getSelectionModel(). getSelection()[0].data.Id" Mode="Raw" />
</ExtraParams>
<EventMask Msg="Carregando..." ShowMask="true" />
</Click>
</DirectEvents>
</ext:Button>

</Items>
</ext:Toolbar>
</TopBar>
<BottomBar>
<ext:PagingToolbar ID="PagingToolbarUsuario" runat="server">
<Items>
<ext:Label ID="Label1" runat="server" Text="Quantidade por p?gina:" />
<ext:ToolbarSpacer ID="ToolbarSpacer1" runat="server" Width="10" />
<ext:ComboBox ID="ComboBox1" runat="server" Width="80">
<Items>
<ext:ListItem Text="1" />
<ext:ListItem Text="2" />
<ext:ListItem Text="10" />
<ext:ListItem Text="30" />
<ext:ListItem Text="40" />
<ext:ListItem Text="50" />
<ext:ListItem Text="60" />
<ext:ListItem Text="100" />
</Items>
<SelectedItems>
<ext:ListItem Value="30" />
</SelectedItems>
<Listeners>
<Select Handler="#{GridPanelUsuario}.store.pageSize = parseInt(this.getValue(), 10); #{GridPanelUsuario}.store.load();" />
</Listeners>
</ext:ComboBox>
</Items>
</ext:PagingToolbar>
</BottomBar>
</ext:GridPanel>
</Items>
</ext:Panel>
...
</Items>
</ext:TabPanel>

My tests
IsPagingStore="true" , AutoLoad="true"

The lines of the grid does not appear. See the image:8891


Any ideia?

Daniil
Mar 26, 2014, 5:54 AM
Hi @luiz,

The problem is here:


return new { usuarios, total };


Please use


return new { data = usuarios, total };

luiz
Mar 26, 2014, 11:45 AM
Hi Daniil,

You're right. My lack of attention.

Please, close this thread.