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

After changing Item in GridViewRow.Item - row is no longer selectable

5 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kestutis
Top achievements
Rank 1
Kestutis asked on 23 Jul 2010, 04:13 PM
I am trying to change data context of row header in handler of RowDetailsVisibilityChanged event.
Only way I have found so far to do this is changing Item property of GridViewRow (which i get from GridViewRowDetailsEventArgs Row property) to desired object, but then row becomes non-selectable and row details no longer expand on clicking changed Row.

Please tell me how to make grid selectable after changing Item, or how to correctly change DataContext of single Row so that it re-renders Header and/or details.

(args.Row.DataContext did not work and args.DetailsElement.DataContext changes data context only of details (but I need also header)).

5 Answers, 1 is accepted

Sort by
0
Milan
Telerik team
answered on 23 Jul 2010, 05:11 PM
Hi Kestutis,

This practice is not recommended. Could you please give us more information about the functionality that you are trying implement.


Kind regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kestutis
Top achievements
Rank 1
answered on 23 Jul 2010, 05:28 PM
First of all we are trying to load extended items to row details context since grid is filled with search results that are light weight (carrying only simple information like title, isPublished, author, create date) and when row is clicked, another call is done to service to get full information for item (with description, text, keywords, tags, images, etc.) and this "full object" then is shown in details by changing args.DetailsElement.DataContext (and details work fine for this).

But problem is when we update extended item (for instance clicking publish button on it), and property IsPublished becomes True (or full object is reloaded with publish date from service), then Row Header is not updated,  because row header is not bound to DetailsElement.DataContext. Therefore we tried to find what should be changed to update Row header information and found out that changing GridViewRow.Item = (our complex object) did the trick, but then Row is no longer selectable :(
0
Milan
Telerik team
answered on 28 Jul 2010, 05:00 PM
Hi Kestutis,

I am afraid that this technique cannot work with RadGridView without breaking our selection mechanism which uses the Item property to mark an item as selected. Fortunately there are many ways implement load on demand. 

One possible implementation is to have the following class structure:

public class Data
{
    public string Title
    {
        get;
        set;
    }
  
    public ExtendedData AdditionalData
    {
        get;
        set;
    }
}
  
public class ExtendedData
{
    public string Description
    {
        get;
        set;
    }
}

Initially you can load the basic data only. When a row details is expanded you can fetch the AdditionalData from the server. That way you will not have to change the Items property of the grid.

Kind regards,
Milan
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Kestutis
Top achievements
Rank 1
answered on 29 Jul 2010, 09:07 AM
Thanks for ideas, it will seem to work but now I get sorting problems.

Thing is - i need to update not just Extended data in your given example, but Data itself (Title of data). I really really want to prevent mapping (like dataInRow.Title = extendedData.Title), therefore I decided to wrap all data inside class called "RowContent", and add property "Content" to it, then bind column properties through Content property so each time i change Content everything updates - details And row header cell values. (and it works - data updates)

BUT now sorting is gone (clicking header cell does not invoke sortin) :( I tried to use:

column.SortMemberPath = "Content.Title";

column.DataMemberBinding =new Binding("Content.Title");

column.UniqueName = "Content.Title";

by specifying only one and/or variation of these ... none of it worked. It seems that columns are sorting only when I add property Title to RowContent class itself.. Can you please help me resolve this?

p.s. I am constructing columns to RadGridView from code behind. and IsSortable + UserCanSortColums are True;
0
Kestutis
Top achievements
Rank 1
answered on 29 Jul 2010, 09:46 AM
I now got this resolved by setting IsCustomSortingEnabled = true for column.
(Since sorting is done on services, I just needed sort descriptors updated).
Tags
GridView
Asked by
Kestutis
Top achievements
Rank 1
Answers by
Milan
Telerik team
Kestutis
Top achievements
Rank 1
Share this question
or