Check ListBox items on DataBound

5 posts, 0 answers
  1. Jordan
    Jordan avatar
    4 posts
    Member since:
    Jun 2015

    Posted 04 Dec 2015 Link to this post

    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!

     

  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 09 Dec 2015 Link to this post

    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.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jordan
    Jordan avatar
    4 posts
    Member since:
    Jun 2015

    Posted 23 Dec 2015 Link to this post

    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

  5. Jordan
    Jordan avatar
    4 posts
    Member since:
    Jun 2015

    Posted 23 Dec 2015 Link to this post

    I submitted a support ticket for this as well.
  6. Jordan
    Jordan avatar
    4 posts
    Member since:
    Jun 2015

    Posted 24 Dec 2015 in reply to Jordan Link to this post

    Persistence Framework does not support persistence of the checkbox filter state at this time.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017