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

[Solved] Hide GridFilterItem on Page_Load

1 Answer 127 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Binod
Top achievements
Rank 1
Binod asked on 15 Jun 2009, 01:53 PM
Hi Telerik

i am using RadGrid with Filter option. and also having a commanditem checkbox which controls Hide/Show of FilterItem.
For example if checkbox is checked then filteritem will be visible otherwise will be invisible.i am controlling it using this javascript code.

 

function showFilterItem(val)

 

{

 

try

 

{

 

var picker = $find("ctl00_ContentPlaceHolder1_User_RadGrid_ctl00_ctl02_ctl00_chkViewFilter");

 

 

 

if (val.checked)

 

{

$find(

'ctl00_ContentPlaceHolder1_User_RadGrid').get_masterTableView().showFilterItem();

 

document.getElementById(

"ctl00_ContentPlaceHolder1_HiddenField8").value=1;

 

}

 

else

 

{

$find(

'ctl00_ContentPlaceHolder1_User_RadGrid').get_masterTableView().hideFilterItem();

 

document.getElementById(

"ctl00_ContentPlaceHolder1_HiddenField8").value=0;

 

}

}

 

catch(ex)

 

{

}

 



 

 

<CommandItemTemplate>

 

 

<table cellpadding="0" cellspacing="0" border="0" width="920px" align="center">

 

 

<tr>

 

 

<td width="675px" align="left" style="padding-right: 15px">

 

 

<asp:CheckBox ID="chkViewFilter" runat="server" Checked="false"   onclick="showFilterItem(this)" />

 

 

<asp:Label ID="Label4" runat="server" Text="Show Filter"></asp:Label>

 

 

</td>

 

</

 

tr>

 

 

</table>

 

 

</CommandItemTemplate>

It is working fine. but my requirement is that In starting/Page_Load  i   want to hide the FilterItem. and this filteritem will be visible only when that checkbox will be checked.
if i try to make FilterItem visible false using this  serverside code then i am unable to make this filteritem visible again using above javascript code.

 

 


if
(!IsPostBack)

 

{

 

foreach (GridFilteringItem filterItem in User_RadGrid.MasterTableView.GetItems(GridItemType.FilteringItem))

 

{

filterItem.Visible =

false;

 

}

}

 

so please guide me how to achieve my result.
Thanks a lot in advance.
Binod.

1 Answer, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 16 Jun 2009, 04:38 AM
Hi Binod,

Give a try with following client side code and see whether it is working fine.

JavaScript:
 
<script type="text/javascript"
function pageLoad() 
    $find("<%=RadGrid1.ClientID %>").get_masterTableView().hideFilterItem(); 
</script> 

-Shinu.
Tags
Grid
Asked by
Binod
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or