We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

dataSource is required to create Manager

Hi,

I've created a new project from the Syncfusion template using the Syncfusion VS extensions. I've created my EF Model and DataContext and used the instructions here to create an editable grid.

Model and DataContext:

    public class Season
    {
        public int Id { get; set; }
        public string SeasonName { get; set; }
    }

    // From DbContext
    public DbSet<Season> Seasons { get; set; }

Here is my controller:

    public class SeasonsController : Controller
    {
        private ApplicationDbContext db = new ApplicationDbContext();

        public ActionResult Index()
        {
            IEnumerable<Season> seasons = db.Seasons;
            return View(seasons);
        }
        public ActionResult Update(Season value)
        {
            Season season = db.Seasons.Find(value.Id);
            season.SeasonName = value.SeasonName;
            db.SaveChanges();
            var data = db.Seasons;
            return Json(data, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Insert(Season value)
        {
            db.Seasons.Add(value);
            var data = db.Seasons;
            return Json(data, JsonRequestBehavior.AllowGet);
        }
        public ActionResult Delete(int key)
        {
            Season season = db.Seasons.Find(key);
            db.Seasons.Remove(season);
            db.SaveChanges();
            var data = db.Seasons;
            return Json(data, JsonRequestBehavior.AllowGet);
        }

        public ActionResult Paul()
        {
            IEnumerable<Season> seasons = db.Seasons;
            return View(seasons);
        }
    }

And here is my index page:

@model IEnumerable<SyncfusionMvcApplication4.Models.Season>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

@(Html.EJ().Grid<SyncfusionMvcApplication4.Models.Season>("Editing")
                .Datasource(ds => ds.Json((IEnumerable<object>)Model).UpdateURL("Seasons/Update").InsertURL("Seasons/Insert").RemoveURL("Seasons/Delete").Adaptor(AdaptorType.RemoteSaveAdaptor))
        .AllowSorting()
        .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); })
            .ToolbarSettings(toolbar =>
            {
                toolbar.ShowToolbar().ToolbarItems(items =>
                {
                    items.AddTool(ToolBarItems.Add);
                    items.AddTool(ToolBarItems.Edit);
                    items.AddTool(ToolBarItems.Delete);
                    items.AddTool(ToolBarItems.Update);
                    items.AddTool(ToolBarItems.Cancel);
                });
            })
        .AllowPaging()
        .Columns(col =>
        {
            col.Field("Id").HeaderText("Id").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(90).ValidationRules(v => v.AddRule("required", true).AddRule("number", true)).Add();
            col.Field("SeasonName").HeaderText("Season Name").TextAlign(TextAlign.Right).Width(90).ValidationRules(v => v.AddRule("required", true)).Add();
        })
)

The page loads but there is no grid. The firebug console picks up this error:

uncaught exception: DataManger : a dataSource is required to create Manager u@http://localhost:49339/Scripts/ej/ej.web.all.min.js:10:70811 t.DataManager@http://localhost:49339/Scripts/ej/ej.web.all.min.js:10:20276 t.DataManager@http://localhost:49339/Scripts/ej/ej.web.all.min.js:10:20248 @http://localhost:49339/Seasons/Index:62:252 x.Callbacks/c@http://localhost:49339/Scripts/jquery-1.10.2.min.js:21:26031 x.Callbacks/p.fireWith@http://localhost:49339/Scripts/jquery-1.10.2.min.js:21:26840 .ready@http://localhost:49339/Scripts/jquery-1.10.2.min.js:21:3303 q@http://localhost:49339/Scripts/jquery-1.10.2.min.js:21:715

I can confirm that there is data in the model from the controller.

Do you see where I am going wrong? I just cannot seem to make it work!

Thanks you,

Paul.

2 Replies

PP Paul Pitchford February 10, 2015 12:04 PM UTC

Don't worry I managed to sort the issue. Off to read more about batch editing now as I'm not sure direct saves are what I need. I think I'd prefer if they entered data and had one save button that amended all changed records.


AS Alan Sangeeth S Syncfusion Team February 11, 2015 08:57 AM UTC

Hi Paul,

Thanks for using Syncfusion Products.

We are happy to hear that you have resolved the issue with Grid render. And please refer the following online sample and UG documentation link for details regarding Batch Editing in Grid.

Online: http://mvc.syncfusion.com/demos/web/grid/batchediting

Documentation: http://help.syncfusion.com/ug/js/documents/template.htm

Please let us know if you need any further assistance.

Regards,
Alan Sangeeth S



Loader.
Live Chat Icon For mobile
Up arrow icon