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

Looking for Example on Grid and Forms Editing with Table and Views

3 Answers 237 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Lee
Top achievements
Rank 1
Lee asked on 08 Feb 2017, 12:27 PM

Hi,

Let me describe the example i am looking for.  Lets say we have following tables.

EMPLOYEE ( EmpNo, Name, FK_DepartmentNo, FK_RoleID)    -- FK stands for foreign key.

DEPARTMENT (DeptNo, DepartmentName)

ROLE ( RoleID, RoleName)

VIEW_EMPLOYEE( EmpNo, Name, DepartmentName, RoleName)

Now I want to use CRUD operation on EMPLOYEE table using Grid.  While listing data in grid, I will list data from View_Employee, but while editing grid I want Insert/Update/Delete to act on EMPLOYEE table.  I want to use Form Template during Edit, so that i can bring appropriate list to fill into Department and Role Dropdown controls respectively.  

Can anyone point me to such a real life example to understand how it can be done with telerik grid.

The Telerik samples of grid shows examples where data comes from single table like Contacts Table or Products Table with simple text columns and that does not simulate real world scenarios.  Hence i am asking this question here.

 

Regards

 

 

 

3 Answers, 1 is accepted

Sort by
0
Eyup
Telerik team
answered on 13 Feb 2017, 07:06 AM
Hello Lee,

You can access the GridEditableItem instance directly using e.Item argument during the UpdateCommand, InserCommand or ItemCommand event handler and depending on your edit mode you can get the values manually:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/rows/accessing-cells-and-rows#accessing-controls-in-editinsert-mode

In some scenarios, the ExtractValues method can be helpful:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/manual-crud-operations/defaultcs.aspx

If you are using templates, make sure that you are using the Bind expression in the form controls in your :
http://msdn.microsoft.com/en-us/library/vstudio/ms178366(v=vs.100).aspx


For example - Text='<%# Bind("SomeField") %>' in order to pass the data back to the query, similar to this live sample:
http://demos.telerik.com/aspnet-ajax/grid/examples/data-editing/form-template-update/defaultcs.aspx

As for editing with combo, the most straightforward way of achieving this is placing a combo control inside the EditItemTemplate of GridTemplateColumn:
http://demos.telerik.com/aspnet-ajax/grid/examples/columns-rows/columns/column-types/defaultcs.aspx


And make avail of the SelectedValue property and the Bind expression as mentioned above.

Alternatively, you can use GridDropDownColumn:
http://demos.telerik.com/aspnet-ajax/grid/examples/columns-rows/columns/column-types/defaultcs.aspx
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/columns/column-types#griddropdowncolumn

The GridDropDownColumn generates a combo control only during insert or edit mode:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/customize-griddropdowncolumn

I hope this will prove helpful.


Regards,
Eyup
Telerik by Progress
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Simon
Top achievements
Rank 1
answered on 25 Jan 2021, 10:52 AM

broken link

http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/customize-griddropdowncolumn

0
Vessy
Telerik team
answered on 26 Jan 2021, 08:59 AM

Hi Simon,

The link to the Customize GridDropDownColumn article has been changed, you can refer it here:

https://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/Common/customize-griddropdowncolumn

Regards,
Vessy
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Lee
Top achievements
Rank 1
Answers by
Eyup
Telerik team
Simon
Top achievements
Rank 1
Vessy
Telerik team
Share this question
or