Store filterdescriptors in database

9 posts, 0 answers
  1. Jan
    Jan avatar
    53 posts
    Member since:
    Oct 2007

    Posted 18 Jan 2017 Link to this post

    Hello,

    I'm looking for the best approach to store a radgridviews filterdescriptors in a db, so that the users could for instance use a dropdown menu to select and save their favourite filter settings. I'm already using the save/load layout funktionality which works great but I would prefer a way to only store the filters.
    Any pointers and suggestions is greatly appretiated.
    Thanks
    Jan

  2. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 18 Jan 2017 Link to this post

    Hello Jan,

    Thank you for writing.

    The grid supports this out of the box and stores layout information as well. Detailed information is available here:  Save and Load Layout | RadGridView.

    I hope this information is useful. Let me know if you need further assistance.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  3. Jan
    Jan avatar
    53 posts
    Member since:
    Oct 2007

    Posted 19 Jan 2017 in reply to Dimitar Link to this post

    Hello,

    Thank you for your quick reply.

    I'm already using the Save and Load Layout functionality, letting the users save and apply their layout.
    However I'm looking for a way to store filters only without having to store the entire layout, so that the users can apply their layout (visible columns, column orders, with etc) and then apply a favourite filter regardless of the selected layout.
    I have looked at this http://docs.telerik.com/devtools/winforms/gridview/save-and-load-layout/advanced but haven't been able to understand how to store the filters only and then apply them without making any changes to the other properties of the grid.

    I hope this is a better explanation of my scenario.

    Kind regards

    Jan

  4. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 19 Jan 2017 Link to this post

    Hello Jan,

    Here is how you can save the filters and layout separately:
    private void radButton1_Click(object sender, EventArgs e)
    {
        radGridView1.XmlSerializationInfo.DisregardOriginalSerializationVisibility = true;
        radGridView1.XmlSerializationInfo.SerializationMetadata.Clear();
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(RadGridView), "MasterTemplate", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewTemplate), "FilterDescriptors", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "PropertyName", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "Operator", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "Value", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "IsFilterEditor", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.SaveLayout("Filters.xml");
     
    }
     
    private void radButton2_Click(object sender, EventArgs e)
    {
        radGridView1.XmlSerializationInfo.DisregardOriginalSerializationVisibility = true;
        radGridView1.XmlSerializationInfo.SerializationMetadata.Clear();
     
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(RadGridView), "MasterTemplate", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewTemplate), "Columns", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "Name", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "Width", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "FieldName", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewDataColumn), "HeaderText", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.SaveLayout("Layout.xml");
     
    }

    I hope this will be useful.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  5. Jan
    Jan avatar
    53 posts
    Member since:
    Oct 2007

    Posted 20 Jan 2017 in reply to Dimitar Link to this post

    Hello Dimitar!

    Thank you this is what I was looking for!
    One more question though. I dont't get it to work when using composite filters.
    I get this:

    <RadGridView>
      <MasterTemplate>
        <FilterDescriptors>
          <Telerik.WinControls.Data.CompositeFilterDescriptor PropertyName="fldBR" Operator="Contains" Value="" IsFilterEditor="True" />
          <Telerik.WinControls.Data.CompositeFilterDescriptor PropertyName="fldOrt" Operator="Contains" Value="" IsFilterEditor="True" />
        </FilterDescriptors>
      </MasterTemplate>
    </RadGridView>

     

    And this is the desired/expected output:

    <RadGridView>
      <MasterTemplate>
        <FilterDescriptors>
          <Telerik.WinControls.Data.CompositeFilterDescriptor NotOperator="False" PropertyName="fldBR" Operator="Contains" Value="" IsFilterEditor="True">
            <FilterDescriptors>
              <Telerik.WinControls.Data.FilterDescriptor PropertyName="fldBR" Operator="IsNotEqualTo" Value="62" IsFilterEditor="False" />
              <Telerik.WinControls.Data.FilterDescriptor PropertyName="fldBR" Operator="IsNotEqualTo" Value="8" IsFilterEditor="False" />
            </FilterDescriptors>
          </Telerik.WinControls.Data.CompositeFilterDescriptor>
          <Telerik.WinControls.Data.CompositeFilterDescriptor NotOperator="False" PropertyName="fldOrt" Operator="Contains" Value="" IsFilterEditor="True">
            <FilterDescriptors>
              <Telerik.WinControls.Data.FilterDescriptor PropertyName="fldOrt" Operator="IsNotEqualTo" Value="London" IsFilterEditor="False" />
            </FilterDescriptors>
          </Telerik.WinControls.Data.CompositeFilterDescriptor>
        </FilterDescriptors>
      </MasterTemplate>
    </RadGridView>

     

    Thank you!

    Kind regards

    Jan

  6. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 20 Jan 2017 Link to this post

    Hi Jan,

    Thank you for writing.

    You should initialise the serialization metadata like this:
    private void radButton1_Click(object sender, EventArgs e)
    {
        radGridView1.XmlSerializationInfo.DisregardOriginalSerializationVisibility = true;
        radGridView1.XmlSerializationInfo.SerializationMetadata.Clear();
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(RadGridView), "MasterTemplate", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(GridViewTemplate), "FilterDescriptors", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(CompositeFilterDescriptor), "FilterDescriptors", DesignerSerializationVisibilityAttribute.Content);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(CompositeFilterDescriptor), "LogicalOperator", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "PropertyName", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "Operator", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "Value", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.XmlSerializationInfo.SerializationMetadata.Add(typeof(FilterDescriptor), "IsFilterEditor", DesignerSerializationVisibilityAttribute.Visible);
        radGridView1.SaveLayout("Filters.xml");
     
    }

    Please do not hesitate to contact us with any additional questions or concerns. 

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
  7. Jan
    Jan avatar
    53 posts
    Member since:
    Oct 2007

    Posted 20 Jan 2017 in reply to Dimitar Link to this post

    Thank you Dimitar,

    This is working like a charm!
    Is there also any simple way to clear the filter settings that has been applied using XmlSerializationInfo?
    I've tried this.radGridView1.MasterTemplate.FilterDescriptors.Clear(); but it doesn't seem to fully reset all the options when using the "excel style" filters.

    Thanks for your patience.

    Kind regards

    Jan

  8. Jan
    Jan avatar
    53 posts
    Member since:
    Oct 2007

    Posted 20 Jan 2017 in reply to Jan Link to this post

    Hello again,

    Solved it byt calling this.radGridView1.LoadLayout(emptylayout.xml);
    And in emptylayout.xml it just says: <RadGridView />

    Thank you

    Jan

     

  9. Dimitar
    Admin
    Dimitar avatar
    2951 posts

    Posted 23 Jan 2017 Link to this post

    Hello Jan,

    Both approaches are correct and working on my side.

    If you want us to further investigate the case with the excel like filters please open a new thread and describe the exact case where the filters are not cleared. 

    Please do not hesitate to contact us with any additional questions or concerns. 
     
    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top