Multiple grids from IEnumerable selection

Jul 3, 2014 at 12:03 PM
Hi,

I'm using two grids on one page, each with a custom view, like this:

@Html.Grid((SortableGrid)ViewBag.ProductList, "_GridFilterPassed").Columns(columns => etc..
@Html.Grid((SortableGrid)ViewBag.RemovedList, "_GridFilterRemoved").Columns(columns => etc..

And I want to use javascript to handle the selection:
    <script type="text/javascript">
            $(function () {
                myGrid.onRowSelect.onRowSelect(function (row) {
                    alert(1);
                });
            });
        </script>
But I can't set the GridRenderOptions.Create("myGrid") when I'm using the IEnumerable/viewName constructor. How can I solve this?
Coordinator
Jul 28, 2014 at 3:16 AM
Hi,

ViewName is a part of GridRenderOptions, use this overload for that:
GridRenderOptions.Create("myGrid", "_GridFilterPassed")
Aug 1, 2014 at 9:30 AM
Thanks for the help.

I managed to fix it like this (which is from the documentation but for some reason it didn't work for me at first):
@Html.Grid((SortableGrid)ViewBag.RemovedList, "_GridFilterRemoved").Columns(columns => <omitted> }).Named("RemovedGrid");
<script type="text/javascript">
  $(function () {
    pageGrids.RemovedGrid.onRowSelect(function (row) {
      alert("Removed table selected, NYI");
    });
  });
</script>
Basically every grid needs a unique name in the .Named() method. Add a new javascript function for each grid.