This project is read-only.

2 independent grids on one page - how to handle gridMvcControl.onRowSelect(function (row)

Apr 3, 2013 at 4:20 PM
Hi I have 2 independent mvc.grids on one page. On each of them I want to fill textboxes with values from grid after onRowSelect event is fired. When I had only one of grid, iw was ok. By adding second grid, it is not working now.

How to do it? Grid must have another id but then what? Thank you very much.
Apr 3, 2013 at 4:29 PM

You need to specify custom grid client id:
And then use pageGrids client object to access the grid:
pageGrids.myGrid.onRowSelect(function (row) { ... });
You can see the sample app in the current release changeset:

Also the following article may help you: Multipile grids on the page
Apr 3, 2013 at 7:33 PM
Thank you very much.
Apr 4, 2013 at 11:26 AM
Edited Apr 4, 2013 at 11:35 AM
I tried it with one grid on page but event is not fired. Do you have idea why? (without GridRenderOptions and with GridMvc.onRowSelect(function (row) it is working fine)

EDITED: explorer said: Jscript error: CustomersFilterWidget is not defined
So without this js line it is working:
pageGrids.myGrid.addFilterWidget(new CustomersFilterWidget());

But I think I will need filtering when I will have 2 grids on page.

@Html.Grid(Model.Items,GridRenderOptions.Create("myGrid")).Columns(columns =>
        columns.Add(x => x.UCP_ID).Titled(RESOURCES.ColumnNameId);
        columns.Add(x => x.UCP_FirstName).Titled(RESOURCES.ColumnNameName);
        columns.Add(x => x.UCP_LastName).Titled(RESOURCES.ColumnNameSurname);
        columns.Add(x => x.UCP_IDCard).Titled(RESOURCES.ColumnNameCardNumber);
        columns.Add(x => x.UCP_IDCardType).Titled(RESOURCES.ColumnNameCardType);
        columns.Add(x => x.UCP_Desc).Titled(RESOURCES.ColumnNameDescription);
        columns.Add(x => x.UCP_ValidFrom).Titled(RESOURCES.ColumnNameValidFrom);
        columns.Add(x => x.UCP_ValidTo).Titled(RESOURCES.ColumnNameValidTo);

pageGrids.myGrid.addFilterWidget(new CustomersFilterWidget());
pageGrids.myGrid.onRowSelect(function (row)
and so on
Apr 4, 2013 at 11:33 AM
I suggest that you don't have referenced CustomersFilterWidget js. This widget uses for demo purposes in sample project. Try to remove pageGrids.myGrid.addFilterWidget(new CustomersFilterWidget()); code line
Apr 4, 2013 at 11:36 AM
Thank you very much. It is working now. :)