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

[Solved] RadGrid OnCreateColumnEditor

4 Answers 405 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dario Zanelli
Top achievements
Rank 1
Dario Zanelli asked on 18 Jan 2010, 05:36 PM
Dear all,

a quick question: I am creating a custom column editor associated to a RadGrid. I can modify items of the grid, delete them or adding new.
I have to avoid changing the code field while modifying the item. Is it possible to  discriminate whether the ColumnEditor has been created pressing the update button or pressing the create new record button? So I can pass a parameter to my CustomEditor.

Thanks in advance.

Kind regards,

Dario Zanelli

4 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 21 Jan 2010, 11:49 AM
Hello Dario,

Thank you for contacting us and for your question.
There are two possible options to address this.
First, from within the CreateColumnEditor server side handler, you can access the RadGrid1.EditIndexes and RadGrid1.MasterTableView.IsItemInserted properties to determine if the control is in edit mode (when the RadGrid1.EditIndexes collection has more than 0 elements), or it is in insert mode (RadGrid1.MasterTableView.IsItemInserted is true).
Alternatively, you can also subscribe to the ItemCommand event handler, which would be raised before CreateColumnEditor. There, you can determine the type of command (initInsert/Edit), and keep this in mind when the CreateColumnEditor is raised subsequently.
I hope one of these approaches is suitable for you. If any other questions aries, do let us know.

Kind regards,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Dario Zanelli
Top achievements
Rank 1
answered on 21 Jan 2010, 12:47 PM
Hello Yavor!
Thanks for the answer, very accurate. I am testing it, but I have another question: I have noticed that I can add a new item and at the same time edit an existing item.
I consider this quite dangerous for my application. Is it possibile to specify a property that avoid this? To allow only one of these two operations.

Regards,

Dario
0
Princy
Top achievements
Rank 2
answered on 21 Jan 2010, 12:51 PM
Hello Dario,

You can go through the following help document which explains on how to switch between the Insert and Edit modes of the grid:
Switching the Insert/Update/Regular Modes

Thanks
Princy.
0
Dario Zanelli
Top achievements
Rank 1
answered on 21 Jan 2010, 01:18 PM
Hi Princy!
Thanks a lot for the answer, it is working properly.
Another one: how can I get the value of a column in the RadGrid item that I am editing (I know the index thanks to the property EditIndexes[0], I can edit only a column)?

Kind regards to all your team!

Dario
Tags
Grid
Asked by
Dario Zanelli
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Dario Zanelli
Top achievements
Rank 1
Princy
Top achievements
Rank 2
Share this question
or