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

Differating Update from Insert when editing in RadGrid

3 Answers 34 Views
Grid
This is a migrated thread and some comments may be shown as answers.
improwise
Top achievements
Rank 1
Iron
Iron
improwise asked on 15 Oct 2010, 11:52 AM
As we all know, RadGrid has many amaing features. But I also find that there are some things missing that feels like it should really have been there form the begining. On of these things, as far as I know, is the inability to differentiate between Updates and Inserts when it comes to editing in the RadGrid. What I mean is something simple like say a Grid with 3 columns where all 3 should be editable when you create a new record, but only 2 of them should be editable on updates (for whatever reason that might be).

This feature has been available in the Microsoft control for as long as I can remember, why is this not the case in the RadGrid? Is it just missing, or is there a good reasons for why it is not available in an easy maintainable way? There are some ways you can do this in code, but that really does seem more like a work around, rather than a really good solution to handle it. Perhaps I am a bit old fashioned, but I don't really like having to write a lot of "GUI code" for stuff that should be built in, mainly because it often gets quite hard to follow, and requires a lot of work to maintain.

So, assuming this feature isn't available and that I have just missed it, what is the best way to implement this, in a way that isn't to much of a nightmare to maintain and implement? Any why isn't it there in an easy way to begin with, I don't think that we can be the only ones with this problem?

3 Answers, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 15 Oct 2010, 01:15 PM
Hi Patrik,

RadGrid does offer properties that you can use in order to distinguish Edit and Insert modes in ItemCreated and ItemDataBound event handlers. You can read in about them in this help article. As a whole, the logic is the following:
private void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
   if(e.Item is GridEditableItem && e.Item.IsInEditMode)
   {
      if(e.Item.OwnerTableView.IsItemInserted)
      {
        //item is about to be inserted
      }
      else
      {
         //item is about to be edited
      }
   }
}


Kind regards,
Tsvetina
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
improwise
Top achievements
Rank 1
Iron
Iron
answered on 15 Oct 2010, 03:41 PM
Sure, but wouldn't that mean that I would have to hard code stuff like "if current field == fieldX then do this and that"? And if we did any changes to the grid, like changing the name of a column or similar, we would then have to go in in and change the code behind? If so, that is what I mean with a solution that works but is a bit frustrating to maintain over time, compared to just modifying the grid using "design features" (wizard etc). Perhaps it comes down to personal taste, but to me, that solution is at best ok, but it isn't good.

Again, might sound like all I do i nagging, but I do consider RadGrid and the Telerik components to be great in most cases.
0
Tsvetina
Telerik team
answered on 21 Oct 2010, 11:41 AM
Hi Patrik,

I see your point. My suggestion is that you submit your suggestion as a feature request and if it is requested by other customers, too, it may be implemented in future releases of RadControls.

Sincerely yours,
Tsvetina
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
Grid
Asked by
improwise
Top achievements
Rank 1
Iron
Iron
Answers by
Tsvetina
Telerik team
improwise
Top achievements
Rank 1
Iron
Iron
Share this question
or