This is a migrated thread and some comments may be shown as answers.

Paging not working after hiding some columns

2 Answers 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Angel
Top achievements
Rank 1
Angel asked on 14 Sep 2011, 12:50 AM
Hello..!
Im working with clientside databinding, When I try to hide some RadGrid  columns this works fine, but the paging stop working..! 
I need to show my columns again (this is the only way i could solve my problem) but showing|hiding my columns again (every page change) is heavy and the performance is affected. Here some code:

This is my grid..!! with only one column
<telerik:RadGrid ID="gdvOrdenes" Width="100%" PageSize="20"
                                        AllowPaging="True" runat="server" EnableViewState="false">
 
          <MasterTableView AutoGenerateColumns="false" AllowFilteringByColumn="True" ShowFooter="True"
           <Columns>
           <%--Grupo del permiso--%>
           <telerik:GridBoundColumn DataField="GrupoPermiso" HeaderText="Grupo permiso" ShowFilterIcon="false"
                                                                                 Resizable="False" SortExpression="GrupoPermiso"  
                                                                                 AutoPostBackOnFilter="true" CurrentFilterFunction="StartsWith"
                                                                                UniqueName="PermissionGroup"/>
                                                                             
            </Columns>
           </MasterTableView>
          <ClientSettings EnableRowHoverStyle="false">                                                                              
          <Scrolling AllowScroll="false" />
          <ClientEvents OnCommand="Solicitudes_Command"/>
          </ClientSettings>
  </telerik:RadGrid>

This function is executed at the begining

function PreparaVistaRadGrid(lista)
{
try {
      
     var listaColumnasBloqueadas =  lista[0].ListaColumnaBloqueadas.split('|');
     var cantidad = tableView.get_columns().length;
     
     //Muestra todas las columnas, Show all columns
     for(var x = 0 ; x < cantidad ;  x++ )
         tableView.showColumn(x);
     
     //Oculta columnas, Hide some columns
     var columnas = tableView.get_columns();
     for(var x = 0 ; x < columnas.length ;  x++ )
        if($.inArray(columnas[x]._data.UniqueName, listaColumnasBloqueadas) >= 0)
           tableView.hideColumn(x);
 
  }
  catch (ex)
  {
     AtraparError("PoolAgente.aspx", arguments, ex);
  }  
}

//This is the function for the Paging, Filtering and Sorting

function Solicitudes_Command(sender, args)
{
  try
  {
     args.set_cancel(true);
 
     commandName = args.get_commandName();
      

     PageMethods.EjecutaConsulta(tableView.get_currentPageIndex() * tableView.get_pageSize(),  tableView.get_pageSize(), tableView.get_sortExpressions().toString(),
                                   tableView.get_filterExpressions().toDynamicLinq(), _tipoAccionSeleccionada, false, RealizoAccion);
      
  }
  catch (ex)
  {
     $find(_nombreRadAjaxLoadingOperations).hide(_nombreGdvOrdenes);
  }
}

Here is where im obligated to hide and show my columns again

function RealizoAccion(result)
{
 try {
    
    //Oculta ventana de loading
    $find(_nombreRadAjaxLoadingOperations).hide(_nombreGdvOrdenes);
 
    tableView.set_dataSource(result.resultado);
    tableView.dataBind();
     
   //HERE IM OBLIGATED TO HIDE/SHOW IN ORDER TO THE "PAGING" WORKS
    //PreparaVistaRadGrid()
    
    if (commandName == "Filter" || commandName == "Load" || commandName == "Page")
        PageMethods.GetCount(updateVirtualItemCount);
        
  }
  catch (ex) {
      AtraparError('Valida Inicio', arguments, ex);
   }   
}

function updateVirtualItemCount(result)
{
   try {
       
      //Se visualiza el número de documentos encontrados
      if(commandName == "Load")
      {
        tableView.set_currentPageIndex(0,true);
      }
       
      tableView.set_virtualItemCount(result);
     
     }
  catch (ex)
  { AtraparError("PoolAgente.aspx", arguments, ex);
  }
}



Please help me, ..!! :(

2 Answers, 1 is accepted

Sort by
0
Angel
Top achievements
Rank 1
answered on 14 Sep 2011, 06:18 PM
Also... i tried using this code (with this the paging works properly)

tableView.get_columns()[x]._element.style.display = 'none';
 
tableView.get_columns()[x]._element.style.display = 'block';
            
But...

 When i try to SHOW a column again with this codeline:
      tableView.get_columns()[x]._element.style.display = 'block';

this does not work!

Resume: When I hide a column this is forever, there's no way to show it again :(
and with the  tableView.hideColumn | tableView.showColumn does not work the paging...!!

What can i do..? Help :(
0
Pavlina
Telerik team
answered on 17 Sep 2011, 08:17 AM
Hello Angel,

I recommend that you examine the project attached by my colleague Tsvetoslav in this forum thread and let me know if it helps to resolve the described problem.

Best wishes,
Pavlina
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal
Tags
Grid
Asked by
Angel
Top achievements
Rank 1
Answers by
Angel
Top achievements
Rank 1
Pavlina
Telerik team
Share this question
or