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

Grid and editable external detail form

3 Answers 37 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Leos
Top achievements
Rank 1
Leos asked on 07 Sep 2010, 07:33 AM
Hello,
I want to have TabControl with two TabItems.
First TabItem will contain RadGridView (BROWSE TAB).
Second TabItem will contail UserControl with textboxes for currently selected/added/edited row (DETAIL TAB).
Detail textboxes will be editable only when row is in editable/append state, otherwise will be readonly.
Second TabItem (DETAIL) will contain toolbar with PREV, NEXT, EDIT, DELETE, ADD, COMMIT and CANCEL command, and buttons will be enabled only if needed (no rows - only ADD is enabled etc). Primary way how to change record will be by buttons on detail form ( not keys in the grid).
Result of all operations will be visible in grid (Grid can be read-only if needed). Primary source (ObservableCollection?, CollectionViewSource?) must be controlled by grid too (for example, source must be sorted when header in grid is clicked).

Does exist some example? Or some tip how to integrate RadGridView with this application logic?
Thank you very much.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 07 Sep 2010, 03:30 PM
Hello Leos,

Following up the sample project from this forum thread,  you can just add a RadTabControl, place the RadGridView in the first RadTabItem and the custom DetailsControl in another one.
As for creating the ToolBar, you may use the commands provided by the RadGridViewCommands class:

ActivateRow 
BeginEdit 
BeginInsert 
CancelCellEdit 
CancelRowEdit 
CommitEdit 
Delete 
MoveDown 
MoveLeft 
MoveNext 
MovePrevious 
MoveRight 
MoveUp 
SelectCurrentItem

You can find an example on their implementation in our demo.

Sincerely yours,
Maya
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
Leos
Top achievements
Rank 1
answered on 09 Sep 2010, 07:37 AM
Hi,
commands MoveNext (MoveUp,...) move focus (cell), not selected or current item (row, record, data object).
When NEXT is clicked I need to move (selected item?) to next record (row) and see next record in detail too.

I also need to have grid in "readonly" state until BeginEdit button is pressed. How?

Which collection type is better to use as Source? CollectionViewSource? ObservableCollection?

Some example with real edit capability will be useful.
Thank you very much.
0
Maya
Telerik team
answered on 09 Sep 2010, 01:04 PM
Hi Leos,

In order to accomplish the functionality of MovingUp/Down and Selecting the next item simultaneously, you can create a new custom command combining two of built-in commands.
For example:

<Button Name="Button1"
    Content="MoveUp"
    Click="Button1_Click" />

private void Button1_Click(object sender, RoutedEventArgs e)
{
    var moveUpCommand = RadGridViewCommands.MoveUp as RoutedCommand;
    var selectCommand = RadGridViewCommands.SelectCurrentUnit as RoutedCommand;
    moveUpCommand.Execute(null, this.playersGrid);
    selectCommand.Execute(null, this.playersGrid);
}

The logic for moving down is pretty much the same except that the MoveDown Command is used.
As for  setting the grid as ReadOnly but still enabling the editing on executing the BeginEdit command, you can just define the grid as ReadOnly and before the execution of the command to set its Property IsReadOnly "False".
Furthermore, considering the best type of collection to uses, the choice depends entirely on the requirements of your application. Most often an ObservableCollection is used. 
  

All the best,
Maya
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
Tags
GridView
Asked by
Leos
Top achievements
Rank 1
Answers by
Maya
Telerik team
Leos
Top achievements
Rank 1
Share this question
or