KanbanFeatures.cshtml
@(Html.EJ().Kanban("Kanban")
.DataSource(ds => ds.URL("GetData").Adaptor(AdaptorType.UrlAdaptor))
) |
KanbanController.cs
public JsonResult GetData(Syncfusion.JavaScript.DataManager value)
{
Task.Add(new Tasks(1, "Open", "Analyze the new requirements gathered from the customer.", "Story", "Low", "Analyze,Customer", 3.5, "Andrew Fuller", "../content/images/kanban/1.png", 1));
Task.Add(new Tasks(2, "InProgress", "Improve application performance", "Improvement", "Normal", "Improvement", 6, "Andrew Fuller", "../content/images/kanban/2.png", 1));
……………………
DataResult result = new DataResult();
DataOperations operation = new DataOperations();
result.result = Task; // result holds data
result.count = Task.AsQueryable().Count(); //count holds card count
if (value.Skip > 0)
result.result = operation.PerformSkip(result.result, value.Skip);
if (value.Take > 0)
result.result = operation.PerformTake(result.result, value.Take);
return Json(result, JsonRequestBehavior.AllowGet);
}
public class DataResult
{
public IEnumerable result { get; set; }
public int count { get; set; }
} |
KanbanFeatures.cshtml
@(Html.EJ().Kanban("Kanban")
.Columns(col =>
{
col.HeaderText("Backlog").Key("Open").Add();
col.HeaderText("In Progress").Key("InProgress").Add();
col.HeaderText("Done").Key("Close").Add();
})
.KeyField("Status") // Based on this key field column key was defined
) |
Hello Buvana,
thank you so much for your answer!
I didn't realize there was a section about the DataManager in the documentation. Will have to read through this more carefully as this will be very helpful for the other controls.
Actually I just copied the code from a ListBox I was using which worked without "Adaptor" but ok, I will be doing this the proper way now :)
Thanks again
Hi Buvana,
actually I do have a follow-up question.
In the sample you uploaded - just like in my own version - drag and drop doesn't really work.
When I drop a card to another column it just resets itself to its original position.
How can I fix that?
Paul
KanbanFeatures.cshtml
@(Html.EJ().Kanban("Kanban")
.DataSource(ds => ds.URL("GetData").CrudURL("Crud").Adaptor(AdaptorType.UrlAdaptor))
) |
KanbanController.cs
public partial class KanbanController : Controller
{
private NORTHWNDEntities db = new NORTHWNDEntities(); // Get all database tables
public ActionResult KanbanFeatures()
{
return View();
}
public JsonResult GetData(Syncfusion.JavaScript.DataManager value)
{
var DataSource = db.Tasks.ToList(); // Get Tasks table list
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);
}
//Edit multiple cards for priority drag and drop
public ActionResult Crud(List<Task> changed, List<Task> added, List<Task> deleted)
{
//Performing insert operation
if (added != null && added.Count() > 0)
{
foreach (var temp in added)
{
db.Tasks.Add(temp);
}
}
//Performing update operation (drag and drop the card and save editing data)
if (changed != null && changed.Count() > 0)
{
foreach (var temp in changed)
{
Task old = db.Tasks.Where(o => o.Id == temp.Id).SingleOrDefault();
if (old != null)
{
db.Entry(old).CurrentValues.SetValues(temp);
}
}
}
//Performing delete operation
if (deleted != null && deleted.Count() > 0)
{
foreach (var temp in deleted)
{
db.Tasks.Remove(db.Tasks.Where(o => o.Id == temp.Id).SingleOrDefault());
}
}
db.SaveChanges();
var data = db.Tasks.ToList();
return Json(data, JsonRequestBehavior.AllowGet);
}
}
public class DataResult
{
public IEnumerable result { get; set; }
public int count { get; set; }
} |