title: MVC3 AD Role based authorization for JQGrid Edit link
body: <p>I am very new to JQgrid and mvc3 . I have a very basic jQgrid with edit functionality.</p>
  
  <p>I want to disable edit link in jqgrid.navgrid  for certain user (autheticated by AD) when JqGrid load and enable it for other user which has diffewrent roles.</p>
  
  <p>I am able to restrict user from editing the grid data but that's not sufficient .I want user not to even see that editable link in JqGrid .    </p>
  
  <p>Here is the JqGrid which  I have in my view( index.cshtml):</p>
  
  <pre><code> jQuery(document).ready(function () {
               jQuery('#list').jqGrid({
               colNames: ['id', 'CountryCode','Node','EligFactor'],
               colModel: [
                         { name: 'id', index: 'id', width: 150, height: 100, align: 'left' },
                         { name: 'CountryCode', index: 'CountryCode', width: 150, align: 'left' },
                         {name: 'Node', index: 'Node', width: 150, height: 100, align: 'left' },
                         {name: 'EligFactor', index: 'EligFactor', width: 150, height: 100, align: 'left', editable: true, edittype: 'text' }
                         ],
              url: '@Url.Action("DynamicGridData")',
              datatype: 'json',
              mtype: 'POST',
              pager: jQuery('#pager'),
              rowNum: 10,
              rowList: [5, 10, 15, 20, 25],
              sortname: 'Id',
              sortorder: "asc",
              viewrecords: true,
              imgpath: '',
              caption: 'Eligibility Factor Grid',
              imgpath: '/Content/images',
              height: '210px'
  
               }).navGrid('#pager', { edit: true, add: false, del: false, search: false, refresh: true },
                   { url: '@Url.Action("EditRecord")', closeAfterEdit: true },
                   {},
  
                   {});
           });
  </code></pre>
  
  <p>2,   Here is the edit method in controller which is being used when user try to edit the grid data :</p>
  
  <pre><code>     [Authorize(Roles=@"MyDomain\SecurityLists\User1")]
          public ActionResult EditRecord(int id, string eligFactor)
          {
              bool success = false;
              var context = new EligibilityFactorDataContext();
              EligibilityControl eg = context.EligibilityControls.Single(p =&gt; p.id == id);
  
              eg.EligFactor = Convert.ToSingle(eligFactor);
  
              try
              {
                  context.SubmitChanges();
                  success = true;
                  return Json(success);
              }
              catch (Exception e)
              {
                  success = false;
                  return Json(success);
                              }
  
          }
  </code></pre>
  
  <p>can someone pl. help me to achieve this . very appreciated ! </p>
  
  <pre><code>var context = new EligibilityFactorDataContext();
  
  
              var isAuth = true;
              int pageIndex = Convert.ToInt32(page) - 1;
              int pageSize = rows;
              int totalRecords = context.EligibilityControls.Count();
              int totalPages = (int)Math.Ceiling((float)totalRecords / (float)pageSize);
              var eligibilitycontrols = context.EligibilityControls.OrderBy(sidx + " " + sord).Skip(pageIndex * pageSize).Take(pageSize);
              var jsonData = new
              {
                total = totalPages,
                page =   page,
                records = totalRecords,
                userdata = isAuth,
                rows = (
                        from eligibilitycontrol in eligibilitycontrols
                        select new
                        {
                          id = eligibilitycontrol.id,
                          cell = new string[]  {
                                                 eligibilitycontrol.id.ToString() ,
                                                 eligibilitycontrol.CountryCode, 
                                                 eligibilitycontrol.Node.ToString(), 
                                                Convert.ToSingle(eligibilitycontrol.EligFactor).ToString()}
  
                                               }).ToArray()
               };
            return Json(jsonData);
      }
  </code></pre>