select row and save in grids

2 posts, 0 answers
  1. Muhammed
    Muhammed avatar
    1 posts
    Member since:
    Jan 2015

    Posted 21 Feb 2016 Link to this post

    Hello Friends.

    I have two grids in my MVC project. One is main Grid which is contain Employee Payments info with custom button [SelectEmployee] to access other grid which is inside a window with all employees list.

    Grid_01 :

    [AddNew][SaveChanges][Cancel][SelectEmployee]
    +-----+-------+-----+
    |EmpId|EmpName|Amout|
    +-----+-------+-----+
    |  01 |Name_01| 5000|
    |  02 |Name_02| 6000|
    |  03 |Name_03| 7000|
    +-------------------+

    Amount is Editable.

    and the second grid which listed all employees inside the window  is like

    Grid_02:

    [Add to Payment]
    -------+-----+-------+-----+------+-------+
    |Select|EmpId|EmpName| Job |Amount|Payment|
    -------+-----+-------+-----+------+-------+
    |  []  |  01 |Name_01| ACC |  5000|  Bank |
    |  []  |  02 |Name_02|  HR |  6000|  Cash |
    |  []  |  03 |Name_03|  IT |  7000|  Cash |
    +-----------------------------------------+

     

    So, My question is. +

    1. when open grid_02 window, if employee already available in Grid_01 then it has to be auto selected (checkbox).

    2. if i select something from Grid_02 and click [Add to Payment] button it has to be auto save in the DB then Grid_01 auto refreshed.

    3. prevent from save/select duplicate data.

  2. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 24 Feb 2016 Link to this post

    Hi,

    Regarding your first question:

    You can handle the dataBound event of the second grid, get with jquery all rows and extract the underlying data item using the dataItem method of the grid. Then you can check if the dataitem’s id is the same as the parent grid’s employee id. If they are the same find with jquery the chekbox in the row and check it. Or call the select method of the grid which will select the row.

    With respect to your second question:
    You can extract the selected row data from the data item by using the dataItem method and update the db with this item. Then you can call .read() method of the first grid’s datasource.

    Regarding your third question:
    This can be achieved by calling a database and return if there is the same record into it as selected in the second grid. If such record exists you can prevent selection.

    I hope this helps.

    Regards,
    Radoslav
    Telerik
     
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
     
Back to Top