How do I filter?

3 posts, 0 answers
  1. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 05 Jun 2012 Link to this post

    Hello,
    I'm creating a dashboard for financial purpose... I've a main viewmodel that composed of

    DateTime SelectionStart {get;set;}
    DateTime SelectionEnd {get;set;}


    I've also an item Indicator class

    public Int ID {get;set}
    public string Description {get;set;}
    [...]
    public IEnumerable<SNAPSHOT> Snapshots {get;set;}


    SNAPSHOT in the meanwhile has

    public int ID {get;set;}
    public double VALUE {get;set;}
    public datetime DT_TS {get;set;}

    I've a radtimebar (with a chart) and a radgridview

    I should display in the gridview the data just for the timebar's selected range... how should I bind the gridview to the filtered data?

    I know I should have a method or property

    public object GetItem()
           {
               var items =SelectedDataItem.SNAPSHOT.Where(o1 => SelectionDateStart < o1.DT_TS && o1.DT_TS < SelectionDateEnd);
     
               return items;
           }

    But if I put this method in the viewmodel I've to manually recreate the relations (I use EF to map data from DB).......any suggestion?
    Thanks
  2. Rossen Hristov
    Admin
    Rossen Hristov avatar
    2477 posts

    Posted 05 Jun 2012 Link to this post

    Hello,

    You need to filter the grid programmatically as describecd in this article. Read the Custom Filtering section. 

    You will add two FilterDescriptors (for start and end time) and update their Value's when the time-bar values change. The grid will do the rest.

    In case you want to do everything in a view model, you can use the QueryableCollectionView class, add the two descriptors to it instead of the grid and then bind the grid to the QCV.

    I hope this helps.

    Greetings,
    Ross
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  3. Michele
    Michele avatar
    426 posts
    Member since:
    Jun 2009

    Posted 05 Jun 2012 Link to this post

    Hello,
    I've clarified the needs with the customer.....since we got a radtimebar on the top he wants that at the selectionchanged only 3 columns of the radgridview below..... how can I do this with filter? Since the grid below shows min/max/average/last value it would really be cool if I can do so...

    Thanks


Back to Top