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

Style or template selector based on the edit status of any cell in the row

3 Answers 55 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Adam
Top achievements
Rank 1
Adam asked on 02 Dec 2011, 03:48 PM
We are trying to develop an RadGridView that has two possible styles/templates for each row and are toggled based on the edit status of any cell within the same row.

Two Row Styles
1) Normal/Initial Status
The row shows basic text-only details
Sample cell contents:  "State - NY"

2) Cell-being-edited Status
When a cell is being edited, it will show labels, comboboxes, datepickers, etc depending on the data type
Sample cell contents: "State - [ComboBox with NY selected]"
(Only one row can be selected and one cell can be edited at any one time)

Behavior
All rows start out in status 1. If a cell is clicked on for editing, that cell and all other cells in that same row switch to status 2.

Roadblocks
We have tried using a DataTemplateSelector to do this logic, but we are having trouble with two aspects
a) What is the best property to key off of in the DataTemplateSelector.SelectTemplate function? What is best way to set the style of all cells based on the edit status of one cell?
b) How can we get DataTemplateSelector.SelectTemplate to evaluate both when a cell is edited and when editing is complete? We can get the cell to change to style 2 upon edit, but not back to style 1 one the edit is complete (CommitEdit or row loses focus)

Thanks for reading

3 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 05 Dec 2011, 08:42 AM
Hello,

 Both style and template selectors will be re-evaluated for specific row if the data item associated with this row is INotifyPropertyChanged and will raise PropertyChanged properly. 

Kind regards,
Vlad
the Telerik team

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

0
Adam
Top achievements
Rank 1
answered on 05 Dec 2011, 04:35 PM
We have looked into using this strategy, but we are having trouble determining where to use/raise the event.

We tried something like this:

public void ForceDataTemplateRefresh()
{
    RaisePropertyChanged(() => ObservableCollectionForWebGrid);
}

Where ForceDataTemplateRefresh was called in the webgrid's SelectionChanged handler.

Can you suggest a better way to force the previously selected and newly selected rows to be re-evaluated?

The closest we have gotten to the desired GUI behavior is to call ourRadGrid.Rebind in the SelectionChanged handler

0
Vlad
Telerik team
answered on 07 Dec 2011, 09:07 AM
Hi,

 I was referring to PropertyChanged for data items - not for the collection property bound to the grid ItemsSource. 

Greetings,
Vlad
the Telerik team

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

Tags
GridView
Asked by
Adam
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Adam
Top achievements
Rank 1
Share this question
or