title: Passing selected rows in a controller in nop Commerce Terilik grid
body: <p>I am beginner in using nopCommerce 2.30 (MVC 3 Razor) and Telerik().Grid. I am currently working </p>
  
  <p>on Nop.Admin project.I try to create a Html.Telerik().Grid in my form, with many features.</p>
  
  <p>Please see my grid image below.</p>
  
  <p><img src="https://i.stack.imgur.com/vgB2Y.png" alt="enter image description here"></p>
  
  <p>These are the features.</p>
  
  <ol>
  <li><p>grid data should be filter the selected value of the dropdownlist. </p></li>
  <li><p>all grid columns are enable sorting.</p></li>
  <li><p>in first column header contains a checkbox,for multiselect.</p></li>
  <li><p>grid view must enable a column context menu.</p></li>
  </ol>
  
  <p>Please see my code below.</p>
  
  <p>My .cshtml file </p>
  
  <pre><code>     &lt;td&gt;
          @(Html.Telerik().Grid&lt;NotificationMailReminderModel&gt;()
                      .Name("productvariants-grid")
  
                      .DataKeys(keys =&gt;
                      {
                          keys.Add(pv =&gt; pv.Username);
                      })
                      .DataBinding(dataBinding =&gt;
                          dataBinding.Ajax()
                                  .Select("EmailReminderByEvent", "Customer")
                      )
                      .Columns(columns =&gt;
                      {
                          columns.Bound(pv =&gt; pv.IsSelected)
                          .ClientTemplate("&lt;input type='checkbox'  name='Id' value='&lt;#= Id #&gt;' /&gt;")
                          .HeaderTemplate(@&lt;text&gt;&lt;input type="checkbox" title="check all records" id="checkAllRecords" /&gt;&lt;/text&gt;)
                          .Width(50)
  
                          .HeaderHtmlAttributes(new { style = "text-align:center" })
                          .HtmlAttributes(new { style = "text-align:center" });
                          columns.Bound(pv =&gt; pv.Username).ReadOnly().Width(250);
                          columns.Bound(pv =&gt; pv.Firstname).ReadOnly();
                          columns.Bound(pv =&gt; pv.Lastname).ReadOnly();
                      })
                              .ClientEvents(events =&gt; events.OnDataBinding("Grid_onDataBinding").OnError("Grid_onError").OnSubmitChanges("Grid_onSubmitChanges")
                              .OnRowDataBound("onRowDataBound"))
                      .Editable(editing =&gt; editing.Mode(GridEditMode.InCell))
                      .Pageable(settings =&gt; settings.PageSize(2).Position(GridPagerPosition.Both))
                      .Sortable(sorting =&gt; sorting.Enabled(true))
          )
          &lt;script type="text/javascript"&gt;
  
              $(document).ready(function () {
                  $('#search-products').click(function () {
                      var grid = $('#productvariants-grid').data('tGrid');
                      grid.currentPage = 1; //new search. Set page size to 1
                      grid.ajaxRequest();
                      return false;
                  });
                  $('#send-mail-reminder').click(function () {
                      var grid = $('#productvariants-grid').data('tGrid');
                      grid.ajaxRequest();
                      return false;
                  });
  
                  $('#grdCustomerEventRoleData #productvariants-grid table thead #checkAllRecords').click(function () {
                      $("#grdCustomerEventRoleData #productvariants-grid table tbody input:checkbox").attr("checked", this.checked);
                  });
              });
  
              function Grid_onError(args) {
                  if (args.textStatus == "modelstateerror" &amp;&amp; args.modelState) {
                      var message = "Errors:\n";
                      $.each(args.modelState, function (key, value) {
                          if ('errors' in value) {
                              $.each(value.errors, function () {
                                  message += this + "\n";
                              });
                          }
                      });
                      args.preventDefault();
                      alert(message);
                  }
              }
  
              function Grid_onDataBinding(e) {
                  var loadData = true;
                  var grid = $(this).data('tGrid');
  
                  if (loadData) {
                      var searchModel = {
                          Event: $('#select-event').val()
                      };
                      e.data = searchModel;
                  }
              }
  
              function Grid_onSubmitChanges(e) {
                  //TODO pass current search parameters
  
                  //we can't pass search parameters in submit changes
                  //that's why let's just clear search params
                  //$('#@Html.FieldIdFor(model =&gt; model.Event)').val('');
                  //$('#SearchCategoryId').val('0');
                  //$('#SearchManufacturerId').val('0');
              }
          &lt;/script&gt;
      &lt;/td&gt;
  </code></pre>
  
  <p>My Controller actions </p>
  
  <pre><code>  public ActionResult EmailReminder()
      {
          if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
              return AccessDeniedView();
  
          var model = new NotificationMailReminderModels();
  
          model.Event = 0;
  
          List&lt;Nop.Core.Domain.Catalog.Product&gt; products = _productRepository.Table.Where(p =&gt; p.EventDate != null &amp;&amp; p.EventDate &gt;= DateTime.MinValue).OrderBy(o =&gt; o.Name).ToList();
  
  
          model.Events = products.Select(p =&gt; new System.Web.Mvc.SelectListItem
          {
              Text = p.Name.Trim(),
              Value = p.Id.ToString()
          }).ToList();
  
          return View(model);
      }
  </code></pre>
  
  <p>[HttpPost, GridAction(EnableCustomBinding = true)]
          public ActionResult EmailReminderByEvent(int[] Id, GridCommand command, NotificationMailReminderModels model)
          {
              if (!_permissionService.Authorize(StandardPermissionProvider.ManageCustomers))
                  return AccessDeniedView();</p>
  
  <pre><code>        var gridModel = new GridModel();
  
          string vwSlEv = ViewBag.SelectedEvent;
          int selevent = 0;
          if (!string.IsNullOrEmpty(vwSlEv))
          {
              Int32.TryParse(vwSlEv, out selevent);
          }
          else
          {
              selevent = model.Event;
          }
  
          var csts = _customerEventRoleRepository.Table.Where(e =&gt; e.EventId == selevent).Select(cs =&gt; cs.CustomerId).Distinct().ToArray();
  
          var customers = _customerRepository.Table.Where(c =&gt; !string.IsNullOrEmpty(c.Username) &amp;&amp; !string.IsNullOrEmpty(c.Email) &amp;&amp; csts.Contains(c.Id)).ToList();
  
          var gridmodel = customers.Select(x =&gt;
          {
              NotificationMailReminderModel not = new NotificationMailReminderModel();
              not.Id = x.Id;
              not.Username = x.Username;
              not.Firstname = x.CustomerAttributes.FirstName;
              not.Lastname = x.CustomerAttributes.LastName;
  
              return not;
          });
  
  
  
          var grddata = new PagedList&lt;NotificationMailReminderModel&gt;(gridmodel.ToList(), command.Page - 1, command.PageSize);
  
          gridModel.Data = grddata;
  
          gridModel.Total = grddata.TotalCount;
  
          return new JsonResult
          {
              Data = gridModel
          };
      }
  </code></pre>
  
  <p>data grid sorting and filtering works fine in my grid. But i can't get the ContextMenu </p>
  
  <p>function in the Razor intellisence.</p>
  
  <p>I want to passing the selected rows to the Controller POST function.</p>
  
  <p>But, How to pass the selected rows in to the controller function.</p>
  
  <p>please help.</p>