We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Persisting Data To The Server: Crud Method Not Run

Hi,
I followed your example and this is my setup:
Razor:

@(Html.EJ().Kanban("Kanban")
.DataSource(ds => ds.URL("GetData").CrudURL("Crud").Adaptor(AdaptorType.UrlAdaptor))
.Columns(col =>
{
col.HeaderText("To Do").Key("ToDo").ShowAddButton(true).Add();
col.HeaderText("In Progress").Key("InProgress").Add();
col.HeaderText("Done").Key("Done").Add();
})
.KeyField("Status")
.AllowTitle(true)
.SelectionType(SelectionType.Single)
.ContextMenuSettings(menu => menu.Enable(true))
.Fields(field =>
{
field.Title("Name")
.Content("Description")
.Color("ColorColumn")
.Tag("Tags")
.Priority("Rank")
.PrimaryKey("Id");
})
.EnableTouch(true)
.EditSettings(edit =>
{
edit.AllowAdding(true).AllowEditing(true)
.EditItems(e =>
{
e.Field("Name").EditType(KanbanEditingType.String).Add();
e.Field("Description").EditType(KanbanEditingType.TextArea).Add();
//e.Field("Status").EditType(KanbanEditingType.Dropdown).Add();
e.Field("Tags").EditType(KanbanEditingType.String).Add();
})
.EditMode(KanbanEditMode.Dialog);
})
))
@Html.EJ().ScriptManager()
Then on the server-side:
public ActionResult Crud(List added, List changed, List deleted)
{}

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.

I have a feeling it's a config problem of some sort or i am missing a step somewhere because the method is run when I move the card.
Appreciate your help and thank you in advance.

4 Replies

BS Buvana Sathasivam Syncfusion Team August 14, 2017 08:48 AM UTC

  
Dear Customer,   
  
Thanks for using Syncfusion product.   
  
We had prepared Kanban control sample with CRUD operations using ejDataManagerURL property is used to load data into Kanban and CrudURL property is used to get post action for processing adding/editing/deleting/updating data’s. You can use the below solution to perform CRUD actions. Please refer to the below code example and sample.       
       
      
[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);    
        }       
 
  
      
       
       
Please refer to the below sample and UG documentation:       
     
   
Please check the sample and let us know if we have misunderstood any of your requirement.  If so, provide more details (like controller page) regarding your requirement so that we can check and provide an appropriate solution.     
   
  
Regards,    
Buvana S.    
 



SY syntax August 16, 2017 04:36 AM UTC

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?



SY syntax August 16, 2017 05:49 AM UTC

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? 



BS Buvana Sathasivam Syncfusion Team August 16, 2017 05:09 PM UTC

Dear Customer, 

Thanks for your update. 
 
The "cancel" request has been triggered first and then CRUD operation was performed when we click the dialog save button. The data values have been added into a data source while CRUD action performed.  After that “save” request has been triggered.  Please find the below video. 
 
 
We were unable to reproduce your reported issue. we can’t deduce the cause of the issue. So, please share more details about the issue (like controller level codes or console script error or simple sample or reproduce your issue on the attached sample) and send it to us so that we can work on solving the issue.   
 

Regards, 
Buvana S. 





Loader.
Up arrow icon