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

[Solved] Cell templates with Dinamic Data

10 Answers 249 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Dario
Top achievements
Rank 1
Dario asked on 27 May 2009, 02:46 PM
My grid view does not have fixed columns, but number and choice of columns varies. What I would like to do is create predefined cell templates ( in some resources...) and dinamically create columns from my data source using those templates. Is there a way to do this? 

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 28 May 2009, 07:24 AM
Hello Dario ,

Indeed you can achieve this very easily if you assign your DataTemplate to CellTemplate or CellEditTemplate column properties. Other possible approach is to inhering from GridViewDataColumn, override CreateCellElement() and/or CreateCellEditElement() and return your own FrameworkElement.

I've attached small examle to illustreate all these.

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dario
Top achievements
Rank 1
answered on 25 Jun 2009, 12:32 PM
Hello Vlad, 
Your post really helped me a lot, but now I have a new problem :(
When I use the templates like you descibed, my header has no sorting or filtering abilities even if I explicitly write IsSortable=true:
  MyColumn otherColumn = new MyColumn(new Binding("Name"));
            otherColumn.HeaderText = "Name";
            otherColumn.IsSortable = true;
            RadGridView1.Columns.Add(otherColumn);

Could it be that this happens because the "CreateCellEement()" method is overriden?

Tnx :)
0
Dario
Top achievements
Rank 1
answered on 26 Jun 2009, 01:04 PM
Me again,
Another problem that I have is that  in some cases I need to add up to a 100 columns dynamically, and for some reason the time it takes to bind columns seem to go up exponentially... I've measured the time it takes to bind 10, 50, 100 columns, and these are the findings:
10 cols: 14 ms
50 cols: 3500 ms
100 cols: 13460 ms
Can anybody give any advice how to optimize this? 
Any help is greatly apreciated :)
0
Nedyalko Nikolov
Telerik team
answered on 30 Jun 2009, 02:22 PM
Hello Dario ,

Indeed current version of the RadGridView has some performance issues with many columns. This problem is with high priority, and will be fixed very soon.

About the previous post - there are some methods you have to override when you inherit from GridViewColumn.
These methods are CanSort(), CanFilter() and CanGroup(). These methods have to check if underlying data source supports required operations.

All the best,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Dario
Top achievements
Rank 1
answered on 01 Jul 2009, 12:28 PM
HI Nedyalko,
Teaks for the reply :)

The thing I want to accomplish is to use filter popup to gather filter information, and then intercept the filtering event, and do my custom filter server side... 
But right now when I click filter button I get exception that my data source does not implement IComparable. So in order to use filter, I need to implement IComparable into my DataSource, just to be able to open filter popup? Another think that confuses me is that that same DataSource works just fine with regular columns (no exception thrown when filtering) although there is no Compare method implemented... :/
I tried to find some answers in the documentation, but this seems too specific case.. so I'm relying on your help on this forum :)
0
Dario
Top achievements
Rank 1
answered on 03 Jul 2009, 09:36 AM
Any chance of a demo how to implement a filter and sort into my custom columns?
The thing is when I implement a IComparable in my source (which is something that I don't like but if I must do it like that ...) I still get filter that doesn't give me any options in filter operator drop down, just "is equal to", and then when i click "Filter" I get some "object reference not set to an instance of an object" exception .... :S
Right now I am really lost.. any help (demo or some tech doc) would mean a lot to me at this point.. 
Tnx
0
Nedyalko Nikolov
Telerik team
answered on 03 Jul 2009, 02:40 PM
Hello Dario ,

Indeed current version of the RadGridView control does not support filtering with a custom object. As a workaround I can suggest you to use custom filtering user control which can handle users input -> filter data on the server -> RadGridView.Rebind().

I'm attaching a sample project which shows how to restyle GridViewHeaderCell in order to insert custom filtering logic (Address column).

Regards,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rana Pratap
Top achievements
Rank 1
answered on 31 Oct 2009, 10:48 AM
HI,

Can any one please tell me which version of RadGridview it is?
because i am using Q2 2009 version and i have the similar requirement.
Please reply me if any suggestiions.

Thanks,
Regards,
Rana Pratap
0
Pankaj Gupta
Top achievements
Rank 1
answered on 02 Nov 2009, 01:02 PM

Hi

I tried your sample but when i tried in mine then even when i double click i dont get my cell in edit mode please help and even i want to show tooltip in every column as a requirement.

Thanks
Pankaj

0
Nedyalko Nikolov
Telerik team
answered on 04 Nov 2009, 10:39 AM
Hi Rana Pratap,

With the 2009.Q2 release you should use your custom control to filter underlying data source. With the 2009.Q3 version there are some improvements to this functionality. You can take a look at this online example. Hope this helps.

Hi Pankaj Gupta,

You can use GridViewColumn.ToolTipTemplate property to set tooltip for a GridViewCell.
Can you provide me with more information about how you cannot enter into edit mode?


Kind regards,
Nedyalko Nikolov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
GridView
Asked by
Dario
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Dario
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Rana Pratap
Top achievements
Rank 1
Pankaj Gupta
Top achievements
Rank 1
Share this question
or