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

Determine row type

4 Answers 107 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 09 Jan 2012, 04:03 PM
How can I determine the grids row type when editing new or existing rows.
I was using grid.itemsource.getType which returns the collection
But if there is no data in the grid it doesn't seem to have a collection but just a single entry.
What the best way to determine the grids type under all code situations.
Thanks
Jim


4 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 09 Jan 2012, 04:09 PM
Hello Jim ,

Typically in the event args you will have the sender visual and or the e.original source.
Having the sender element  you can easily get the parent row and check its type .
However there is no unified approach for "all code situations". I can give a  specific assistance for a specific case if needed . What exactly you are trying to achieve ?

Greetings,
Pavel Pavlov
the Telerik team

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

0
Jim
Top achievements
Rank 1
answered on 09 Jan 2012, 04:40 PM
I have a service which validates a cells contents.
When the service returns if has the grids name but not the rowType
So it can get a reference to the grid with

Dim

 

 

radGridView As RadGridView = LayoutRoot.FindName(gridName)

 


I am trying to validate both
1) Cells in existing rows
2) Cells in new row ( ie Click here to add new row ) in a grid with existing rows.
3) Cells in new row ( ie Click here to add new row ) in a grid with no existing rows.

Thanks
Jim
0
Jim
Top achievements
Rank 1
answered on 10 Jan 2012, 08:44 AM
A bit more info.
Typically our grids contain columns of abbreviations and a column of descriptions
It might be cities e.g.
| City  |  Description |
+------+---------------+
| LON | London UK |
| BER | Berlin DE    |
| PAR | Paris   FR   |

When editing a row , be it existing or new when we enter say "LON" in the first cell and the cell validates on "tab out" then the validation routine fires off a request to the server. When the server "eventually" returns the event handling routine has the grid name and column name and row index. The row index is a problem as it is sometimes -1 ( usually on insert ).

Either LON was found with it's description in this case the description cell is updated ( in the model data ).
If not found then a validation error is inserted into the model data and the Description set to blank.
This approach works with the assumption that -1 is the last entry in the model.

However when inserting a new row into a blank grid we have discovered problems determing the row type.
Hope this helps ...
Jim


0
Nedyalko Nikolov
Telerik team
answered on 11 Jan 2012, 02:25 PM
Hi Jim,

Generally you could get the underlying item type from row.Item.GetType(). An instance of a row you can get within RadGridView.RowEditEnded event handler as e.Row. 
If this does not help could you please provide me with a little bit more information about your scenario and your requirements?

Greetings,
Nedyalko Nikolov
the Telerik team

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

Tags
GridView
Asked by
Jim
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Jim
Top achievements
Rank 1
Nedyalko Nikolov
Telerik team
Share this question
or