title: How to rebind Json object with Telerik MVC grid
body: <p>I<code>m having problem with rebinding grid with Json object….
  I</code>m trying to create custom delete button…
  So far I have Jquery function: Gets an ID of selected column (username) and call controller action “UserDetails”</p>
  
  <p>Delete button:</p>
  
  <pre><code>$("#DeleteUser").click(function () {
      if (id != "") {
          var answer = confirm("Delete user " + id)
          if (answer) {
              $.ajax({
                  type: "POST",
                  url: "/Admin/UserDetails",
                  data: "deleteName=" + id,
                  success: function (data) {
  
                  }
              });
          }
      } else {
          $("#erorMessage").html("First you must select user you whant to delete!");
      }
  });
  </code></pre>
  
  <p>This is action controller  UserDetails(string startsWith, string deleteName)</p>
  
  <pre><code>[GridAction]
      public ActionResult UserDetails(string startsWith, string deleteName)
      {   // Custom search...
          if (!string.IsNullOrEmpty(startsWith))
          {
              return GetSearchUserResult(startsWith);
          }
          if (!string.IsNullOrEmpty(deleteName))
          {
              TblUserDetails user = db.TblUserDetails.Single(a =&gt; a.TblUser.userName == deleteName);
              try
              {
                  TblUser userToDelete = db.TblUser.Single(a =&gt; a.userId == user.TblUser.userId);
                  db.DeleteObject(user);
                  db.DeleteObject(userToDelete);
  
                  db.SaveChanges();
                  Membership.DeleteUser(deleteName);
  
                  List&lt;UserDto&gt; retModelData = new List&lt;UserDto&gt;();
                  //GetAllUsers() returns a List&lt;UserDto&gt; of users.
                  retModelData = GetAllUsers();
  
                  var model = new GridModel
                  {
                      Data = retModelData,
                      Total = GetAllUsers().Count()
                  };
                  return View(model);
              }
              catch
              {
                  return View(new GridModel());
              }
          }
  
          else
          {
              var user = GetAllUsers();
              return View(new GridModel(user));
          }
      }
  </code></pre>
  
  <p>So far everything is working OK. But can I bind my grid with these Json data and how???
  <a href="http://dl.dropbox.com/u/15702806/Untitled.jpg" rel="nofollow">This is my Json result </a> that I want to bind with grid...</p>
  
  <p>And here is my grid:</p>
  
  <pre><code>@(Html.Telerik().Grid&lt;App.Web.Models.UserDto&gt;()
  .Name("Grid")
  .DataKeys(key =&gt;
  {
      key.Add(a =&gt; a.Id);
  })
  .Columns(column =&gt;
  {
      column.Bound(a =&gt; a.Username).Filterable(false);
      column.Bound(a =&gt; a.FirstName).Filterable(false);
      column.Bound(a =&gt; a.LastName).Filterable(false);
      column.Bound(a =&gt; a.Email).Filterable(false);
  })
  .DetailView(detailView =&gt; detailView.ClientTemplate(
                  "&lt;table id='DetailTable'&gt;&lt;tbody&gt;&lt;tr class='UserRow'&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;First name&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;#= FirstName #&gt;&lt;/td&gt;"
                          + "&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;"
                          + "&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Last name&lt;/b&gt;&lt;/td&gt;"
                          + "&lt;td&gt;&lt;#= LastName #&gt;&lt;/td&gt;"
                          + "&lt;td id='Roles'&gt;&lt;/td&gt;&lt;td id='Operations'&gt;&lt;/td&gt;"
                          + "&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Username&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;#= Username #&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Address&lt;/b&gt;&lt;/td&gt;"
                          + "&lt;td&gt;&lt;#= Address #&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Email&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;#= Email #&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Birth date&lt;/b&gt;&lt;/td&gt;"
                          + "&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Registration date&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Phone number&lt;/b&gt;&lt;/td&gt;"
                          + "&lt;td&gt;&lt;#= PhoneNumberHome #&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td class='Tbllable'&gt;&lt;b&gt;Mobile number&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;#= PhoneNumberMobile #&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;"
                  ))
  //.EnableCustomBinding(true)
  .DataBinding(bind =&gt; bind.Ajax().Select("UserDetails", "Admin", new { startsWith = ViewBag.startsWith }))
  .Pageable(paging =&gt;
          paging.PageSize(12)
                .Style(GridPagerStyles.NextPreviousAndInput)
                .Position(GridPagerPosition.Bottom)
      )
  .ClientEvents(e =&gt; e
      .OnRowDataBound("Expand")
      .OnRowSelect("select")
      .OnLoad("replaceConfirmation")
  )
      .RowAction(row =&gt;
      {
          if (row.Index == 0)
          {
              row.DetailRow.Expanded = true;
          }
      })
  .Editable(editing =&gt; editing.Mode(GridEditMode.PopUp))
  .Selectable()
  .Sortable()
  </code></pre>
  
  <p>)</p>