This is a migrated thread and some comments may be shown as answers.

AJAX Editor not Updating

0 Answers 54 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Kacee
Top achievements
Rank 1
Kacee asked on 05 Aug 2014, 01:57 PM
I have used the Entity Framework in order to pull my SQL data and to make a grid, but when I go to update it doesn't do anything, but the cancel button has proper functionality. I am not sure what I am doing wrong here. I have followed the tutorial from the Kendo page in order to do this; therefore, I am not sure what I have missed.

Model
public class PQAViewModel
  {
     public string Jobber { get; set; }
     public int Dealer { get; set; }
     public int OptInd { get; set; }
     public DateTime establish_date_time { get; set; }
     public string establish_id { get; set; }
  }


View
@(Html.Kendo().Grid<TelerikMvcApp1.Models.PQAViewModel>()
     .Name("grid")
     .Columns(columns =>
         {
              columns.Bound(opt => opt.Jobber).Width(90);
              columns.Bound(opt => opt.Dealer).Width(95);
              columns.Bound(opt => opt.OptInd).Width(110);
              columns.Bound(opt => opt.establish_date_time);
              columns.Bound(opt => opt.establish_id);
               columns.Command(commands =>
        {
                              commands.Edit();
        }).Title("Commands").Width(200); 
     })
            .Editable(editable => editable.Mode(GridEditMode.InLine))
            .Filterable()
            .Pageable()
            .DataSource(datasource =>
            datasource.Ajax()
              .Model(model =>
                   {
                       model.Id(opt => opt.Dealer);
                       model.Field(opt => opt.Jobber).Editable(false);
                       model.Field(opt => opt.Dealer).Editable(false);
                       model.Field(opt => opt.OptInd).Editable(true);
                       model.Field(opt => opt.establish_date_time).Editable(false);
                       model.Field(opt => opt.establish_id).Editable(false);
                    })
                   .PageSize(20)
                   .Read(read => read.Action("ProductQualityFileFull_Read", "PQA"))
                   .Update(update => update.Action("Opt_Update", "PQA"))
                      )
                  )



Controller

namespace TelerikMvcApp1.Controllers
   {
       public class PQAController : Controller
           {

               public ActionResult Baseline()
               {
                      return View();
               }

               public ActionResult ProductQualityFileFull_Read([DataSourceRequest] DataSourceRequest request)
                 {
                       using (var pqa = new PQAEntities())
                    {
                       IQueryable<ProductQualityFileFull> opt = pqa.ProductQualityFileFulls;
                       DataSourceResult result = opt.ToDataSourceResult(request);
                       return Json(result);
                    }
                }

               public ActionResult UpdateOptIn()
                  {

                      return View();

                  }


           public ActionResult Opt_Update([DataSourceRequest] DataSourceRequest request, PQAViewModel opt)
           {
               if (ModelState.IsValid)
                {
                     using (var pqa = new PQAEntities())
                {
                        var entity = new ProductQualityFileFull
                   {
                         Jobber = opt.Jobber,
                         Dealer = opt.Dealer,
                         OptInd = opt.OptInd,
                         establish_date_time = opt.establish_date_time,
                         establish_id = opt.establish_id
                      };

              pqa.ProductQualityFileFulls.Attach(entity);

              pqa.Entry(entity).State = EntityState.Modified;
 

             pqa.SaveChanges();
              }
           }

               return Json(new[] { opt }.ToDataSourceResult(request, ModelState));

      }
   }


 

 





No answers yet. Maybe you can help?

Tags
Grid
Asked by
Kacee
Top achievements
Rank 1
Share this question
or