The GetData works great; however I just cannot seem to get the Crud action to be hit when i add a new card or edit a card. I did nto try deleting but I suspect it won;t delete either. However, when I move a card the Crud method gets hit.
[cshtml]
@(Html.EJ().Kanban("Kanban")
.DataSource(ds =>
// To load data using “GetData” method.
ds.URL("GetData")
// added, changed, and deleted data’s can get in the CrudURL post action.
.CrudURL("Crud").Adaptor(AdaptorType.UrlAdaptor)) //Define the DataManger.
) |
[controller]
private NORTHWNDEntities db = new NORTHWNDEntities();
public ActionResult GetData(Syncfusion.JavaScript.DataManager value) //To render all Kanban cards. {
var DataSource = db.Tasks.ToList();
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) // Called Crud method when adding, updating and deleting operation performed
{
//Performing insert operation
if (added != null && added.Count() > 0)
{
foreach (var temp in added)
{
db.Tasks.Add(temp);
}
}
//Performing update operation
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);
} |
Hi,
Thank you for the reply. i am doing all that and I just double checked.
When I move the card, or delete it, I see the busy icon on the screen - and it hits my Crud ActionResult breakpoint.
But whenever I add or update, the screen just flashes and goes back to how it was. The breakpopint in my Crud ActionResult is not hit.
Since the control hits the Action when the card is moved or deleted, I believe everything is correct however, for some reason, add and edit methods after clicking save on the dialog is not hit. Unfortunately, the edit dialog does not allow me to debug anything so all I see is screen resetting itself.
Have you ever seen this behavior?
OK, have some more data after some digging in.
I created a client Side Event;
.ClientSideEvents(eve =>
eve.ActionComplete("complete"))
then on my javascript;
<script>
function complete(args) {
alert(args.requestType);
}
</script>
When I click "Edit Card", beginEdit is fired as expected. However, when I make a change on the edit card, and hit save, then cancel is the request type and I think this is the root of all of my problems. Something is not tied correctly.
So, what can I do? Shall I get the latest? - I have 2017.2, and I know that 2017.3 is out. Or would defining a dialog template help?