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

Check ListBox items on DataBound

4 Answers 231 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Jordan
Top achievements
Rank 1
Jordan asked on 04 Dec 2015, 05:35 PM

Hello,

 I am using a "Combined" filter type on a RadGrid and some of my columns use the CheckList filter like the one shown below. 

<telerik:GridBoundColumn
    DataField="State" HeaderText="State" ReadOnly="true" HeaderStyle-Width="40px" FilterControlWidth="40px"
    ItemStyle-Width="40px" AutoPostBackOnFilter="true" UniqueName="State" SortExpression="State"
    FilterCheckListEnableLoadOnDemand="false" FilterControlAltText="Filter State column" CurrentFilterFunction="StartsWith"/>

We are using a persistence manager to restore the state of the grid, sometimes this includes values that were checked in the column above. When restoring from the persistence manager, the grid is filtered correctly however, the values are not checked in the FilterCheckList.

 I tried checking the values in the DataBound event handler for the list box and the values get selected correctly but not checked correctly.

private void ListBox_DataBound(object sender, EventArgs e)
{
    RadListBox listBox = sender as RadListBox;
    string filter = grdOpportunities.MasterTableView.FilterExpression;
    filter = filter.Replace("AND", "&");
    string[] filters = filter.Split('&');
 
    foreach (string f in filters)
    {
        if (f.Contains(listBox.DataKeyField))
        {
            string current = f.Replace("OR", "&");
            string[] options = current.Split('&');
 
            foreach (string o in options)
            {
                foreach (RadListBoxItem item in listBox.Items)
                {
                    if (o.Contains(item.DataKey.ToString()))
                    {
                        item.Selected = true;
                        item.Checked = true;
                    }
                }
            }
        }
    }
}
Attached is what I see after this code block is executed. 

Please advise, thank you!

 

4 Answers, 1 is accepted

Sort by
0
Peter Filipov
Telerik team
answered on 09 Dec 2015, 09:14 AM
Hello Jordan,

Could you please send me a runnable sample where I could observe the problem? 

Regards,
Peter Filipov
Telerik
 

Consider using RadControls for ASP.NET AJAX (built on top of the ASP.NET AJAX framework) as a replacement for the Telerik ASP.NET Classic controls, See the product support lifecycle here.

 
0
Jordan
Top achievements
Rank 1
answered on 23 Dec 2015, 07:57 PM

Peter,

 Here is a link to a runnable demo: https://drive.google.com/file/d/0B_is1WIRqr-jTWF4d0dvYUx0aGM/view?usp=sharing

With this demo you are able to filter the grid by check box, save the state, and restore the state. When restoring, the check boxes are no longer checked.

Thanks,

Jordan

0
Jordan
Top achievements
Rank 1
answered on 23 Dec 2015, 08:25 PM
I submitted a support ticket for this as well.
0
Jordan
Top achievements
Rank 1
answered on 24 Dec 2015, 01:51 PM
Persistence Framework does not support persistence of the checkbox filter state at this time.
Tags
ListBox
Asked by
Jordan
Top achievements
Rank 1
Answers by
Peter Filipov
Telerik team
Jordan
Top achievements
Rank 1
Share this question
or