<script>
/*Change event for Dropdown control*/
function dataChanged(args) {
debugger;
/*Get Data for Treeview and TreeGrid*/
var name = args.text, value;
$.ajax
({
url: "Gantt/GetGanttData",
async: false,
data: { text: name },
type: 'GET',
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (result) {
value = result.dataSource;
$("#GanttContainer").ejGantt("model.dataSource", value);
},
error: function (data) {
alert("error");
}
});
}
</script>
[CS]
public JsonResult GetGanttData(string text)
{
List<BusinessObject> ds = new List<BusinessObject>();
if(text=="DataSource1")
ds = this.GetPlanDataSource();
else
ds = this.GetDesignDataSource();
return Json(new { dataSource = ds }, JsonRequestBehavior.AllowGet);
}
|
<script>
/*Change event for Dropdown control*/
function dataChanged(args) {
debugger;
/*Get Data for Treeview and TreeGrid*/
var name = args.text, value;
$.ajax
({
url: "Gantt/GetGanttData",
async: false,
data: { text: name },
type: 'GET',
dataType: "json",
contentType: "application/json;charset=utf-8",
success: function (result) {
value = result.dataSource;
$("#GanttContainer").ejGantt("model.dataSource", value);
},
error: function (data) {
alert("error");
}
});
}
</script>
[CS]
public JsonResult GetGanttData(string text)
{
List<BusinessObject> ds = new List<BusinessObject>();
if(text=="DataSource1")
ds = this.GetPlanDataSource();
else
ds = this.GetDesignDataSource();
return Json(new { dataSource = ds }, JsonRequestBehavior.AllowGet);
}
|
public ActionResult Index()
{
//
ViewBag.datasource = this.GetPlanDataSource();
DataManagerConverter.Serializer = new DMSerial();
return View();
}
public class DMSerial : IDataSourceSerializer
{
public string Serialize(object obj)
{
var str = Newtonsoft.Json.JsonConvert.SerializeObject(obj);
return str;
}
} |
//Triggered on drop down change action
function change(args) {
var data = { id: args.value };
//ajax call to server side method to refresh partialView
$.ajax({
data: data,
url: '@Url.Action("_Gantt", "Gantt")',
success: function (data) {
$("#GanttContainer").ejGantt("destroy");
$("#container").html(data);
},
error: function (result) {
alert("Error");
}
});
} |
[HttpGet]
public ActionResult _Gantt(int id)
{
var DataSource = this.GetDesignDataSource(id);
ViewBag.datasource = DataSource;
DataManagerConverter.Serializer = new DMSerial();
return PartialView("_Gantt", DataSource);
} |
I tried everything as you said. Nothing is working. The whole setup is as follows:
- Scripts are loaded through Layout page
<script src="~/JsScript/PageScripts/HRIMS_Secure/jquery-2.1.4.min.js"></script>
<script src="http://code.jquery.com/ui/1.12.0/jquery-ui.min.js"></script>
<script src="~/JsScript/Gantt/jquery.easing-1.3.min.js"></script>
<script src="~/JsScript/Gantt/jsrender.min.js"></script>
<script src="~/JsScript/Gantt/ej.web.all.js"></script>
<script src="~/JsScript/Gantt/ej/ej.unobtrusive.min.js"></script>
-Layout page also contains @(Html.EJ().ScriptManager())
- <add key="UnobtrusiveJavaScriptEnabled" value="false" />(I still needs to load ej.unobtrusive.min.js the chart is not at all working)
- Index.cshtml contains PartialView(_Gantt) which is attached here.Please find attachment.
- $('#drp').change(function () {
$.ajax({
url: urlGetGantt,
data: {Id: $(this).val() },
success: function (data) {
$("#GanttContainer").ejGantt("destroy");
$("#Gantt").html(data);
}
});
});
Above is the change event of the dropdown. After refresh no errors are there. Only below html is loaded if i view it in console
<div id="Gantt">
<link rel='nofollow' href="/CSS/ej.widgets.core.min.css" rel="stylesheet">
<link rel='nofollow' href="/CSS/ej.theme.min.css" rel="stylesheet">
<link rel='nofollow' href="http://cdn.syncfusion.com/13.1.0.21/js/web/flat-azure/ej.web.all.min.css" rel="stylesheet">
<div id="GanttContainer" data-role="ejgantt" data-ej-enablecontextmenu="true" data-ej-allowcolumnresize="true".......</div><script>ej.createObject("ej.dataSources.GanttContainer",{"data0":ej.isJSON([{........</script>
This is the method in controller
[HttpGet]
public ActionResult gantt(int Id)
{ GanttData objGanttData = new GanttData();
if (Id != 0)
{
objGanttData.LstTaskData = GetData(iteration);
objGanttData.LstTaskData = GetData(iteration);
objGanttData.StripLines = GetStriplines();
}
objGanttData.LstAllResource = GetResources();
objGanttData.objPriorityCodes = JsonConvert.SerializeObject(GetPriorities(), Formatting.None);
objGanttData.objProjectWiseStatus = JsonConvert.SerializeObject(GetStatus(), Formatting.None);
objGanttData.objWorkItemTypes = JsonConvert.SerializeObject(GetWorkItemType(), Formatting.None);
DataManagerConverter.Serializer = new DMSerial();
return PartialView("gantt", objGanttData);
}
Note: Chart stops working only after partial view refresh. If we pass data at the time of page load,it gets rendered as expected.
I'm really getting confused as what is missing here.