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

[Solved] RadGrid Filter

4 Answers 178 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Anil
Top achievements
Rank 1
Anil asked on 28 Jan 2010, 03:34 PM
Hi, I have a radgrid which has radio buttons on the commanditemtemplate.
There are two issues with it.
1. On the pageload I cannot get the control by its name but I have to use document.getElementById with the client id. Don't know why.
2. Bigger issue is that the selection made on the radio buttons do not stick after postback.
If I move thse controls outside the grid, everything works fine though.

Appreciate your help.

Thanks,
Anil



<telerik:RadCodeBlock runat="server" ID="radCodeBlock">  
        <script type="text/javascript">  
            function pageLoad(sender, args) {  
                var radShowYes = document.getElementById('ctl00_ContentPlaceHolder1_RadGrid1_ctl00_ctl02_ctl00_radShowHideYes');  
                if (radShowYes.checked)  
                    $find('<%=RadGrid1.ClientID %>').get_masterTableView().showFilterItem();  
                else  
                    $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();  
            }  
            function showFilterItem(){  
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().showFilterItem();  
            }   
            function hideFilterItem(){  
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();  
            }  
</script> 
</telerik:RadCodeBlock> 
 
<telerik:RadGrid ID="RadGrid1" runat="server" Width="96%" GridLines="None" Skin="Vista">  
...  
 
<MasterTableView DataKeyNames="ReferralID" Width="100%"   
            CommandItemDisplay="Top" AllowFilteringByColumn="true"   
            AllowMultiColumnSorting="false" AlternatingItemStyle-BackColor="Beige">  
            <CommandItemTemplate> 
                <div style="padding: 5px 5px;">  
                &nbsp;&nbsp;&nbsp;&nbsp;  
                    <asp:LinkButton ID="btnInitInsert" runat="server" CommandName="InitInsert" CausesValidation="false">  
                        <img style="border:0px;vertical-align:middle;" alt="" src="../Images/AddRecord.gif" />Add new Record  
                    </asp:LinkButton> 
                   
 
Show filters <input id="radShowHideYes" type="radio" runat="server" name="showHideGroup" onclick="showFilterItem()" /> 
                    <label for="radShowHideYes">Yes</label>   
                    <input id="radShowHideNo" type="radio" runat="server" name="showHideGroup" checked="true" onclick="hideFilterItem()"/>  
                    <label for="radShowHideNo">No</label>      
                    Clear filters  
                    <asp:ImageButton ID="btnShowAll" runat="server" ImageUrl="~/Images/CancelSmall.gif" OnClick="btnShowAll_Click" 
                        Style="vertical-align: middle" /> 
                </div> 
            </CommandItemTemplate> 
.......  

<

 

ClientSettings>

 

 

<Scrolling AllowScroll="false" />

 

 

<ClientEvents OnFilterMenuShowing="filterMenuShowing" />

 

 

</ClientSettings>

 

 

<FilterMenu OnClientShown="MenuShowing" />

 

 
 
 

4 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 29 Jan 2010, 01:15 PM
Hello Anil,

 You are using html input controls that are not rendered on the server and this is the reason why they are not accessible on the server and do not persist their state. Try using regular asp:RadioButton controls by attaching the client event handlers to their onclick event and setting AutoPostBack=false.

<asp:RadioButton ID="radShowHideNo" onclick="hideFilterItem()" runat="server" />

I hope this helps.

All the best,
Tsvetoslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Anil
Top achievements
Rank 1
answered on 29 Jan 2010, 07:53 PM
Thanks Tsvetoslav for your help.

Well, it solves the problem of finding the control by $find...
But the radiobutton still does not retain value I select in the radiobutton after the filter dropdown item is selected or I type something in the filter. The filters have autopostback true.
All these controls are in a ap:content tag.

What am I missing?

Thanks,
Anil
0
Lee Malo
Top achievements
Rank 1
answered on 01 Feb 2010, 04:44 PM
Im having the same issue, it works but my radio buttons are not retaining state, They are also in an ajaxified grid
0
Shinu
Top achievements
Rank 2
answered on 02 Feb 2010, 07:55 AM
Hi,

The issue with the radio buttons may be caused due to the rebind of the grid that happens internally on filtering. If so you will need to persist the state as shown in a help link below that is on a similar scenario:



Thanks,
Shinu

Tags
Grid
Asked by
Anil
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
Anil
Top achievements
Rank 1
Lee Malo
Top achievements
Rank 1
Shinu
Top achievements
Rank 2
Share this question
or