Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9141877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:42:12+00:00 2026-06-17T09:42:12+00:00

I am client-server, SQL programmer (RAD guy) and the company decided that we must

  • 0

I am client-server, SQL programmer (RAD guy) and the company decided that we must move to .NET environment. We are examining the platform now.

I studied the MVC4 and the Entities Framework this week and I have read a lot about KendoUI. I was skeptical because most of the examples come with KendoGrid+WebApi. I know awfully little about WebApi but I really liked the Entities thing a lot so I do not think I should give it a chance.

I want to ask some question which may seem naive but the answers will help me a lot

  1. Once I create entities from an existing database, can I have the results in Json format and with this to feed a KendoGrid?

    If yes, how? I mean:

  2. How I can convert the results in Json inside the Controller?

  3. In the transport property of the KendoGrid I should put the URL of the Controller/Action?

    and the most naive one

  4. Does Telerik have any thoughts of providing a visual tool to create-configure the kendoGrid? To make it more RAD because now need TOO MUCH coding. Maybe a wizard that you can connect entities with Grid columns, datasource, transport selectors etc..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:42:13+00:00Added an answer on June 17, 2026 at 9:42 am

    I hope you choose the Kendo Entities path, there will be a learning curve though. No, on question 4. But let me give you a jump start using the Razor view engine and answer 1, 2, and 3.

    First, EF is creating business objects. You ‘should’ convert these to Models in MVC. In this example Person is from EF. I think of this as flattening because it removes the depth from the object, though it i still available so you could reference something like Person.Titles.Name if your database was setup like that. You can also drop in DataAnnotations, which just rock.

    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;
    using System.Linq;
    using Project.Business;
    
    namespace Project.Web.Models
    {
        public class PersonModel
        {
            public int Id { get; set; }
            [Required(ErrorMessage = "Last Name is required.")]
            public string LastName { get; set; }
            [Required(ErrorMessage = "First Name is required.")]
            public string FirstName { get; set; }
            [Display(Name = "Created")]
            public System.DateTime StampCreated { get; set; }
            [Display(Name = "Updated")]
            public System.DateTime StampUpdated { get; set; }
            [Display(Name = "Enabled")]
            public bool IsActive { get; set; }
    
            public PersonModel()
            {}
            public PersonModel(Person person)
            {
                Id = person.Id;
                FirstName = person.FirstName;
                LastName = person.LastName;
                StampCreated = person.StampCreated;
                StampUpdated = person.StampUpdated;
                IsActive = person.IsActive;
            }
    
            public static IList<PersonModel> FlattenToThis(IList<Person> people)
            {
                return people.Select(person => new PersonModel(person)).ToList();
            }
    
        }
    }
    

    Moving along…

    @(Html.Kendo().Grid<PersonModel>()
        .Name("PersonGrid")
        .Columns(columns => {
            columns.Bound(b => b.Id).Hidden();
            columns.Bound(b => b.LastName).EditorTemplateName("_TextBox50");
            columns.Bound(b => b.FirstName).EditorTemplateName("_TextBox50");
            columns.Bound(b => b.StampUpdated);
            columns.Bound(b => b.StampCreated);
            columns.Bound(b => b.IsActive).ClientTemplate("<input type='checkbox' ${ IsActive == true ? checked='checked' : ''} disabled />").Width(60);
                columns.Command(cmd => { cmd.Edit(); cmd.Destroy(); }).Width(180);
            })
        .ToolBar(toolbar => toolbar.Create())
        .Pageable()
        .Filterable()
        .Sortable()
        .Selectable()
        .Editable(editable => editable.Mode(GridEditMode.InLine))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Events(events => events.Error("error_handler"))
            .Model(model =>
                {
                    model.Id(a => a.Id);
                    model.Field(a => a.StampCreated).Editable(false);
                    model.Field(a => a.StampUpdated).Editable(false);
                    model.Field(a => a.IsActive).DefaultValue(true);
                })
            .Create(create => create.Action("CreatePerson", "People"))
            .Read(read => read.Action("ReadPeople", "People"))
            .Update(update => update.Action("UpdatePerson", "People"))
            .Destroy(destroy => destroy.Action("DestroyPerson", "People"))
            .PageSize(10)
        )
    )
    

    Those _TextBox50 are EditorTemplates named _TextBox50.cshtml that MUST go either in a subfolder relative to your view or relative to your Shared folder – the folder must be called EditorTemplates. This one looks like this…

    @Html.TextBox(string.Empty, string.Empty, new { @class = "k-textbox", @maxlength = "50" })
    

    Yes, thats all. This is a simple example, they can get much more complicated. Or you don’t have to use them initially.

    And finally, what I think you are really looking for…

    public partial class PeopleController : Controller
    {
        private readonly IPersonDataProvider _personDataProvider;
    
        public PeopleController() : this(new PersonDataProvider())
        {}
        public PeopleController(IPersonDataProvider personDataProvider)
        {
            _personDataProvider = personDataProvider;
        }
    
        public ActionResult Manage()
        {
    >>> Left in as teaser, good to apply a special Model to a View to pass goodies ;)
            var model = new PeopleViewModel();
            model.AllQualifications = QualificationModel.FlattenToThis(_qualificationDataProvider.Read());
            return View(model);
        }
    
        [HttpPost]
        public JsonResult CreatePerson([DataSourceRequest]DataSourceRequest request, Person person)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    person = _personDataProvider.Create(person);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError(string.Empty, e.InnerException.Message);
                }
            }
            var persons = new List<Person> {person};
            DataSourceResult result = PersonModel.FlattenToThis(persons).ToDataSourceResult(request, ModelState);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
    
        public JsonResult ReadPeople([DataSourceRequest]DataSourceRequest request)
        {
            var persons = _personDataProvider.Read(false);
            DataSourceResult result = PersonModel.FlattenToThis(persons).ToDataSourceResult(request);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
    
        [HttpPost]
        public JsonResult UpdatePerson([DataSourceRequest]DataSourceRequest request, Person person)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    person = _personDataProvider.Update(person);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError(string.Empty, e.InnerException.Message);
                }
            }
            var persons = new List<Person>() {person};
            DataSourceResult result = PersonModel.FlattenToThis(persons).ToDataSourceResult(request, ModelState);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
    
        [HttpPost]
        public JsonResult DestroyPerson([DataSourceRequest]DataSourceRequest request, Person person)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    person = _personDataProvider.Destroy(person);
                }
                catch (Exception e)
                {
                    ModelState.AddModelError(string.Empty, "There was an error deleting this record, it may still be in use.");
                }
            }
            var persons = new List<Person>() {person};
            DataSourceResult result = PersonModel.FlattenToThis(persons).ToDataSourceResult(request, ModelState);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
    }
    

    Notice that, in this case, each method takes the EF Person as a parameter, it would be better to use PersonModel but then I would have to show the opposite of the Flatten. This works becuase they are practically identical. If the model was different or you were using a class factory it gets a bit more tricky.

    I intentionally showed you all the CRUD operations. If you don’t pass the result back to the grid it will act funny and give you dupicates or not show updates correctly on CREATE and UPDATE. It is passed back on DELETE to pass the ModelState which would have any errors.

    And finally the data provider, so as to leave nothing to the imagination…
    (Namespace declaration omited.)

    using System;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Linq;
    using Project.Business;
    
    public class PersonDataProvider : ProviderBase, IPersonDataProvider
    {
        public Person Create(Person person)
        {
            try
            {
                person.StampCreated = DateTime.Now;
                person.StampUpdated = DateTime.Now;
    
                Context.People.Attach(person);
                Context.Entry(person).State = EntityState.Added;
                Context.SaveChanges();
                return person;
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                throw;
            }
        }
    
        public IList<Person> Read(bool showAll)
        {
            try
            {
                return (from q in Context.People
                          orderby q.LastName, q.FirstName, q.StampCreated
                          where (q.IsActive == true || showAll)
                          select q).ToList();
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                throw;
            }
        }
    
    ...
    
    }
    

    Note the Interface and ProviderBase inheritance, you have to make those. Should be simple enough to find examples.

    This may seem like a lot of coding, but once you get it down, just copy paste.

    Happy coding.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .NET client that needs to connect to a remote SQL Server
i want to install my client an application that uses SQL Server 2008 database.
I have an application that runs on a client's server built on a SQL
I'm having trouble getting a client/server implementation of Quartz.NET working. I have a SQL
We have a client running our .NET application which connects to SQL Server 2005
We have an enterprise application written in asp.net c# (3.5) and SQL server that
I have a thick client written in VB6 that connects to an Sql Server
I am developing a Client-Server application using C# .NET Winforms with SQL Server 2008.
When a client connection with the SQL Server (from client side ) is cut,
Our client wants to support both SQL Server and Oracle in the next project.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.