Determine row type

5 posts, 0 answers
  1. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 09 Jan 2012 Link to this post

    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


  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 09 Jan 2012 Link to this post

    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 >>

  3. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 09 Jan 2012 Link to this post

    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
  4. Jim
    Jim avatar
    68 posts
    Member since:
    Apr 2011

    Posted 10 Jan 2012 Link to this post

    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


  5. Nedyalko Nikolov
    Admin
    Nedyalko Nikolov avatar
    871 posts

    Posted 11 Jan 2012 Link to this post

    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 >>

Back to Top