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

select row and save in grids

1 Answer 218 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Muhammed
Top achievements
Rank 1
Muhammed asked on 21 Feb 2016, 10:23 AM

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.

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 24 Feb 2016, 08:58 AM
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!
 
Tags
Grid
Asked by
Muhammed
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or