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

GridView bound to indexer

4 Answers 127 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Przemysław
Top achievements
Rank 1
Przemysław asked on 06 Nov 2014, 02:44 PM
Hello,
I'm creating datagrid with dynamically created columns. The ViewModel looks like:
public string this[Guid column]
 {     
    get { ....}
    
set { ... }
}

And I create columns this way:
GridViewDataColumn col = new GridViewDataColumn();<br>
col.Header = c.Column.Name;<br>
col.DataMemberBinding = new Binding(String.Format("[{0}]", c.Column.Id)) { FallbackValue = null };
col.ColumnGroupName = g.Header;
 
this.Columns.Add(col);


I had some problems - sorting (fixed by custom ICollectionView link) but now I have issue with filtering. When i try to filter, grid becomes empty. And also I cannot see list with checkboxes to select desired values (like for normal column bound to string property).

Is there anything I can do with that? ICollectionView  has filter property, but it's not used in Telerik Datagrid (?).

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 07 Nov 2014, 03:24 PM
Hello,

Would you please try specifying a proper DataType for each of the columns bound the indexer's values. That way the sorting and filtering should work fine.

Let me know if this helps.


Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Przemysław
Top achievements
Rank 1
answered on 12 Nov 2014, 09:23 AM
Hi,

Nope, that doesn't help - see screenshot.

I'm creating columns this way (currently all of them are strings):
GridViewDataColumn col = new GridViewDataColumn();
col.Header = c.Column.Name;
col.DataMemberBinding = new Binding(String.Format("[{0}]", c.Column.Id)) { IsAsync = true, FallbackValue = null };
col.ColumnGroupName = g.Header;
col.FilterMemberPath = "";
 
switch (c.Column.Type)
{
    case ComplinkTableColumnType.Double:
        col.DataType = typeof(double);
        col.FilterMemberType = typeof(double);
        break;
    case ComplinkTableColumnType.Integer:
        col.DataType = typeof(int);
        col.FilterMemberType = typeof(int);
        break;
    case ComplinkTableColumnType.Bool:
        col.DataType = typeof(bool);
        col.FilterMemberType = typeof(bool);
        break;
    default:
        col.DataType = typeof(string);
        col.FilterMemberType = typeof(string);
        break;
}
 
Columns.Add(col);

And as you see, filters are for strings but listbox with values to select is empty.

Kind Regards,
0
Dimitrina
Telerik team
answered on 14 Nov 2014, 12:25 PM
Hi,

I am sorry to hear my suggestion did not help.

I will try to elaborate more on how the filtering actually works. It is a data operations which means it is done by building and executing a LINQ query appending proper Where clause over the source collection. 
For example:
var result = collection.Where(item => item.Property == "Something");

The reason for not working should be that our data engine cannot build a valid LINQ query based on the specified binding. 
So, if you can build such a LINQ query appending Where clause based on the DataMemberBinding set for a column, then RadGridView should also be able to filter the respective column. Otherwise, this will not be possible.

If you can build a valid LINQ query and RadGridView still does not show filtering options, then may I ask you to isolate the case in a demo project which I can check locally? You can open a new support ticket and attach it there.


Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Przemysław
Top achievements
Rank 1
answered on 20 Nov 2014, 12:10 PM
Hi,

I've managed to do it. Just by creating a bunch of generic 'bridge' objects for each of data types.
If indexer is returing strongly typed data (not just object) it will work.
So for T columns I'm creating proxy object with
public T this[string columnId] {get (...)}
And bounding column to it to ViewModel.TProxy["guid"]

Cheers,
Tags
GridView
Asked by
Przemysław
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Przemysław
Top achievements
Rank 1
Share this question
or