This question is locked. New answers and comments are not allowed.
Hi
Telerik Team,
I have to use mvc Grid with ajax binding support. So i have reach a One Probleam.
first i have to create a our ViewModel class.
and Use the model class to ajax binding. our Controller Source code is-
and my view Page Source is -
Now my problem is -
If i have not use a commend button, then Ajax binding is properly work with Pagination.
But if use a commend button with ajax binding , then Pagination And Commend not working.
also You check this url
http://classifi.w03.winhost.com/Employers/jobList
i have not found why this problem is occur.
Please check it . and tell me what the mistak on my code.
Telerik Team,
I have to use mvc Grid with ajax binding support. So i have reach a One Probleam.
first i have to create a our ViewModel class.
public class ViewJobModel { public int CompanyID {get ;set;} public string CompanyInfo {get ;set;} public string ContactName{get ;set;} public DateTime DateInserted {get ;set;} public bool IsActive {get ;set;} public int JobID {get ;set;} public string JobTitle {get ;set;} }and Use the model class to ajax binding. our Controller Source code is-
using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.Mvc;using ITClassifieds.Models;using System.Data.EntityClient;using System.Data;using Telerik.Web.Mvc;using Telerik.Web.Mvc.UI;namespace ITClassifieds.Controllers.Employers{ public partial class EmployersController : Controller { // job list Action : Responsable for Show jobs list on view Page public ActionResult jobList() { var job = (from u in db.Jobs where u.User.UserID == 77396 select new ViewJobModel { CompanyID = u.User.UserID , CompanyInfo = u.CompanyInfo , ContactName = u.ContactName , DateInserted = u.DateInserted , IsActive = u.IsActive , JobID = u.JobID , JobTitle = u.JobTitle }); return View(job); //return View(GetAllJobs()); } [GridAction] public ActionResult _FirstLook() { var job = (from u in db.Jobs where u.User.UserID == 77396 && u.IsActive == true select new ViewJobModel { CompanyID = u.User.UserID, CompanyInfo = u.CompanyInfo , ContactName = u.ContactName , DateInserted = u.DateInserted , IsActive = u.IsActive , JobID = u.JobID , JobTitle = u.JobTitle }); return View(new GridModel { Data = job }); // return View(new GridModel(GetAllJobs() //.Select(s => new { JobID = s.JobID, JobTitle = s.JobTitle, IsActive = s.IsActive, DateInserted = s.DateInserted, ContactName=s.ContactName }) // )); } [AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _SaveAjaxEditing(int id) { var job = (from u in db.Jobs where u.User.UserID == 77396 && u.IsActive == true select new ViewJobModel { CompanyID = u.User.UserID, CompanyInfo = u.CompanyInfo , ContactName = u.ContactName , DateInserted = u.DateInserted , IsActive = u.IsActive , JobID = u.JobID , JobTitle = u.JobTitle }); return View(new GridModel { Data = job }); } [AcceptVerbs(HttpVerbs.Post)] [GridAction] public ActionResult _DeleteAjaxEditing(int id) { //Find a customer with ProductID equal to the id action parameter var job = (from u in db.Jobs where u.User.UserID == 77396 && u.IsActive == true select new ViewJobModel { CompanyID = u.User.UserID, CompanyInfo = u.CompanyInfo , ContactName = u.ContactName , DateInserted = u.DateInserted , IsActive = u.IsActive , JobID = u.JobID , JobTitle = u.JobTitle }); return View(new GridModel { Data = job }); } private IEnumerable<Job> GetAllJobs() { //where u.User.UserID == 77396 ClassifiedEntities db = new ClassifiedEntities(); var job = (from u in db.Jobs where u.User.UserID == 77396 && u.IsActive == true select u).OrderBy(n => n.JobID); return job; } public ActionResult JobPostingStatistics() { var totaljobs = (from j in db.Jobs where j.User.UserID == 77396 select j).Count(); ViewData["totaljobs"] = totaljobs; var isactive = (from j in db.Jobs where j.User.UserID == 77396 && j.IsActive == true select j).Count(); ViewData["isactive"] = isactive; var isInactive = (from j in db.Jobs where j.User.UserID == 77396 && j.IsActive == false select j).Count(); ViewData["isInactive"] = isInactive; var hits = (from j in db.Jobs where j.User.UserID == 77396 && j.IsActive == true select j).Count(); ViewData["hits"] = hits; return View(); } }}and my view Page Source is -
<%@ Page Title="" Language="C#" MasterPageFile="~/Content/Employers.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %><asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server"> jobList</asp:Content><asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server"> <h2>jobList</h2> <%= Html.Telerik().Grid<ViewJobModel>() .Name("Grid") .DataKeys(keys => keys.Add(o => o.JobID)) .Columns(columns => { columns.Bound(o => o.JobID).Width(100); columns.Bound(o => o.JobTitle).Width(100); columns.Bound(o => o.IsActive).Width(200) .ClientTemplate("<input type='checkbox' disabled='disabled'name='IsActive' <#= IsActive? checked='checked' : '' #> />"); columns.Bound(o => o.DateInserted).Width(200); columns.Bound(o => o.ContactName).Width(120); columns.Command(commands => { commands.Edit().ButtonType(GridButtonType.Text); commands.Delete().ButtonType(GridButtonType.Text); }).Width(200).Title("Command"); }) .DataBinding(dataBinding => { dataBinding.Ajax() .Select("_FirstLook","Employers") .Update("_SaveAjaxEditing", "Employers") .Delete("_DeleteAjaxEditing", "Employers"); }) .Editable(editing => editing.Mode(GridEditMode.InLine)) .Scrollable(s=>s.Enabled(true)) .Sortable(so=>so.Enabled(true)) .Pageable(p=>p.Enabled(true)) .Filterable(f=>f.Enabled(true)) .Groupable(g=>g.Enabled(true)) .Footer(true) %></asp:Content>Now my problem is -
If i have not use a commend button, then Ajax binding is properly work with Pagination.
But if use a commend button with ajax binding , then Pagination And Commend not working.
also You check this url
http://classifi.w03.winhost.com/Employers/jobList
i have not found why this problem is occur.
Please check it . and tell me what the mistak on my code.