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

Show filter row on grid initial load

1 Answer 37 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Tracy
Top achievements
Rank 1
Tracy asked on 18 Oct 2014, 05:35 PM
Hi,

I am trying to show/hide the filter row on the grids initial load.  I have the following script set and based on the alert messages the code is running correctly but the filter row isn't being displayed when it should be.



Can you tell me what I am missing.

Thanks for you assistance.

Tracy
function GridInitialLoad(sender, eventArgs) {
    
    var masterTable = sender.get_masterTableView();
    var rbtFilter = $telerik.findControl(sender.get_element(), "rbtFilters");
    var i = 0;
    var result;
    var toggleList;
     
    if (rbtFilter) {
        toggleList = rbtFilter.get_selectedToggleStateIndex();
        switch (toggleList) {
            case 0:
                rbtFilter.set_toolTip('Show Filter Row');
                masterTable.hideFilterItem();
                alert('hide');
                break;
            case 1:
                rbtFilter.set_toolTip('Hide Filter Row');
                masterTable.showFilterItem();
                alert('show');
                break;
        }
         
    }
 
    var rbtGroup = $telerik.findControl(sender.get_element(), "rbtGrouping");
    if (rbtGroup) {
        toggleList = rbtGroup.get_selectedToggleStateIndex();
        switch (toggleList) {
            case 0:
                rbtGroup.set_toolTip('Show Group Panel');
                result = $telerik.$(".rgGroupPanel");
                for (i = 0; i < result.length; i++) {
                    result[i].className = "hideGroupPanel";
                }
                break;
            case 1:
                rbtGroup.set_toolTip('Hide Group Panel');
                result = $telerik.$(".hideGroupPanel");
                for (i = 0; i < result.length; i++) {
                    result[i].className = "rgGroupPanel";
                }
                break;
        }
    }
 
            
 
   }

<telerik:RadGrid ID="rgvMainGrid"       runat="server"                  DataSourceID="SQLDS_EmailAddresses"  
                    EnableEmbeddedSkins="true"         Skin="Office2010Silver"         EnableAjaxSkinRendering="true"        Height="550px"  Width="1230px"
                    EnableViewState="true"             AutoGenerateColumns="false"     AllowMultiRowSelection="false"     
                    AllowFilteringByColumn="true"      EnableHeaderContextMenu="true"  EnableHeaderContextFilterMenu="true"  ShowGroupPanel="true"  
                      
                    AllowAutomaticDeletes="false"      AllowAutomaticInserts="false"   AllowAutomaticUpdates="false"                                 
                    AllowSorting="true"                EnableLinqExpressions="false"   AllowPaging="true"  PageSize="100"    >                                 
                   <ItemStyle              Wrap="true"  />
                   <AlternatingItemStyle   Wrap="true" />
                   <ActiveItemStyle        BackColor="CornflowerBlue"/>
                   <EditItemStyle           Font-Size="10px" />
                    
                   <HeaderStyle            HorizontalAlign="Center"/>
                   <PagerStyle             AlwaysVisible="true"        Mode="NextPrevNumericAndAdvanced"/>
                   <EditItemStyle      BackColor="CornflowerBlue"/>     
                   <ClientSettings     AllowColumnsReorder="true"      ReorderColumnsOnClient="true"       ColumnsReorderMethod="Reorder"   AllowDragToGroup="true"  EnablePostBackOnRowClick="false"    EnableRowHoverStyle="false"  
                       <ClientEvents   OnGridCreated="GridInitialLoad" OnRowSelected="SetSelectedItem" />
                       <Resizing       AllowColumnResize="true"        EnableRealTimeResize="true"         ResizeGridOnColumnResize="true"  AllowRowResize="false" />
                       <Selecting      AllowRowSelect="true"/>
                       <Scrolling      AllowScroll="true"              UseStaticHeaders="true" />                       
                   </ClientSettings>
                   <GroupHeaderItemStyle Font-Size="11px"              Font-Names="calibri"                Font-Bold="true"  Height="12px"/>
                   <MasterTableView    Name="Users"                    DataSourceID="SQLDS_EmailAddresses"   DataKeyNames="EmailAddressID, EmailName"  ClientDataKeyNames="EmailAddressId, EmailName"
                                       Width="1213px"                  EnableViewState="true"              EditMode="InPlace"            CommandItemDisplay="Top"   TableLayout="Fixed"
                                       EnableGroupsExpandAll="true"    GroupLoadMode="Client"              EnableNoRecordsTemplate="true"  ShowHeadersWhenNoRecords="true" >                                                                                                             
                   <NoRecordsTemplate>There are no records that match the criteria you selected!</NoRecordsTemplate>
                    



1 Answer, 1 is accepted

Sort by
0
Angel Petrov
Telerik team
answered on 22 Oct 2014, 11:26 AM
Hello Tracy,

In a scenario where the filter item should be shown is it being first hidden on the server? Note that if this is the case a filter item will not be rendered at all and it is expected for the client-side logic to not display it. If you follow such an approach I recommend removing the server-side logic and only hiding the filter item on the client when necessary.

If the issue persist after modifying the logic according to the above please share with us the entire page contents so we could examine the implementation and advice you further.

Regards,
Angel Petrov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Tracy
Top achievements
Rank 1
Answers by
Angel Petrov
Telerik team
Share this question
or