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

2 posts, 0 answers
  1. Lee
    Lee avatar
    49 posts
    Member since:
    Feb 2010

    Posted 08 Feb 2017 Link to this post

    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

     

     

     

  2. Eyup
    Admin
    Eyup avatar
    3841 posts

    Posted 13 Feb 2017 Link to this post

    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.
Back to Top