|
View:
@(Html.EJ().Kanban("Kanban")
.DataSource(ds => ds.URL("GetData").CrudURL("Crud").Adaptor(AdaptorType.UrlAdaptor))
.Columns(col =>
{
col.HeaderText("Backlog").Key("Open").Add();
col.HeaderText("In Progress").Key("InProgress").Add();
col.HeaderText("Done").Key("Close").Add();
})
.ClientSideEvents(eve => eve.CardDragStart("cardDragStart"))
.AllowTitle(true)
.AllowSelection(true)
.KeyField("Status")
.Fields(field =>
{
field.Color("Type")
.Content("Summary")
.PrimaryKey("Id");
})
.EditSettings(edit =>
{
edit.AllowAdding(true)
.AllowEditing(true)
.EditItems(e =>
{
e.Field("Id").Add();
e.Field("Status").EditType(KanbanEditingType.Dropdown).Add();
e.Field("Assignee").EditType(KanbanEditingType.Dropdown).Add();
e.Field("Summary").EditType(KanbanEditingType.TextArea).Add();
});
})
)
//button to change the datasource
<input type="button" id="buttton" value="changeDatasource" onclick="changeClick(this)" />
<script>
function changeClick(args) {
var kObj = $("#Kanban").data("ejKanban");
var dataManger = ej.DataManager({ url: "/Kanban/GetDatanew" });
kObj.setModel({ dataSource: dataManger })
}
</script>
Controller:
public JsonResult GetDatanew(Syncfusion.JavaScript.DataManager value) //new datasource method
{
var DataSource = db.Tasks.ToList(); // new table datasource called via setmodel.
DataResult result1 = new DataResult();
DataOperations operation = new DataOperations();
result1.result = DataSource;
result1.count = DataSource.AsQueryable().Count();
if (value.Skip > 0)
result1.result = operation.PerformSkip(result1.result, value.Skip);
if (value.Take > 0)
result1.result = operation.PerformTake(result1.result, value.Take);
if (value.Select != null && value.Select.Count > 0)
return Json(result1.result, JsonRequestBehavior.AllowGet);
return Json(result1, JsonRequestBehavior.AllowGet);}
} |
I am going to set up a SignalR Hub with the Kanban Control, I would like to set the client's hub based on how they navigated to the page. My hope is to have abstracted out the view enough such that I can reuse it for any hub. After writing out my requirements I am thinking the way to go is to send environment context in the ViewModel or ViewBag, then I could use javascript on the page to parse the Model to determine which Hub to connect to. Once the hub is connected I would then need to populate the Kanban Control with Javascript... am I on the right track?
Matt