Hi,
I have an MVC 5 application and I purchased the Javascript licence some days ago.
I've been trying to make a grid that request data from the server, but I couldn't.
After read so many posts I arrived to the following solution but still without compiling:
Error: Can not find the type or namespace name 'Syncfusion' (are you missing a using directive or an assembly reference?)
BTW: I have the references added on my solution
- Syncfusion.Core
- Syncfusion.EJ
Could you help me and tell me where I'm doing wrong? OR what is the best way to load data from the server using Javascript Platform and MVC as code behind?
Thanks!!
Here is the View:
@{
ViewBag.Title = "KMS - Syncfusion Grid Example";
ViewBag.xsTitle = "Syncfusion Grid Example";
Layout = null;
}
<link rel='nofollow' href="@Url.Content("~/Content/ej.widgets.core.min.css")" rel="stylesheet" />
<link rel='nofollow' href="@Url.Content("~/Content/ej.widgets.core.bootstrap.min.css")" rel="stylesheet" />
<link rel='nofollow' href="@Url.Content("~/Content/bootstrap-theme/ej.widgets.all.min.css")" rel="stylesheet" />
@Scripts.Render("~/bundles/syncfusion-needs")
<script src="~/Scripts/Syncfusion/web/ej.web.all.js"></script>
<div class="content-container-fluid">
<div class="row">
<div class="cols-sample-area" style="height:550px">
<div id="Grid"></div>
</div>
</div>
</div>
<script type="text/javascript">
$(function () {
var dataManger = ej.DataManager({
url: "@Url.Action("_GetEmployees", "Syncfusion")"
});
$("#Grid").ejGrid({
dataSource: dataManger,
allowPaging: true,
pageSettings: { pageSize: 9 },
columns: [
{ field: "Employee_ID", headerText: "Employee ID", isPrimaryKey: true, width: 75, textAlign: ej.TextAlign.Right },
{ field: "Employee_LName", headerText: "Last Name" },
{ field: "Employee_FName", headerText: "First Name" },
{ field: "UserName", headerText: "UserName" }
]
});
});
</script>
Bundle:
bundles.Add(new ScriptBundle("~/bundles/syncfusion-needs").Include(
"~/Scripts/jquery-2.1.4.js",
"~/Scripts/jquery.easing.1.3.js",
"~/Scripts/jquery.globalize.js",
"~/Scripts/jsrender.js"));
Controller
using KMSApplications.Models;
using KMSDataAccess;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Syncfusion.Core;
using Syncfusion.JavaScript;
namespace KMSApplications.Controllers
{
public class SyncfusionController : BaseController
{
// GET: Syncfusion
public ActionResult Index()
{
return View();
}
public ActionResult _GetEmployees(DataManager dm)
{
var model = DataServiceLocator.GetEmployee_DAO()
.GetAll(Context)
.Select(x => new EmployeeModel
{
Active = x.Active ?? false,
Email = x.Email,
Employee_FName = x.Employee_FName,
Employee_ID = x.Employee_ID,
Employee_LName = x.Employee_LName,
UserName = x.UserName
});
var Data = model as IEnumerable;
int count = model.Count();
Syncfusion.JavaScript.DataSources.DataOperations operation = new Syncfusion.JavaScript.DataSources.DataOperations();
if (dm.Sorted != null && dm.Sorted.Count > 0) //Sorting
{
Data = operation.PerformSorting(Data, dm.Sorted);
}
if (dm.Where != null && dm.Where.Count > 0) //Filtering
{
Data = operation.PerformWhereFilter(Data, dm.Where, dm.Where[0].Operator);
}
if (dm.Skip != 0)
{
Data = operation.PerformSkip(Data, dm.Skip);
}
if (dm.Take != 0)
{
Data = operation.PerformTake(Data, dm.Take);
}
return Json(new { result = Data, count = count }, JsonRequestBehavior.AllowGet);
}
}
}