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

DragAndDrop with different grid source

I want to drag with this grid :

@(Html.EJ().Grid<CodeLibelle>("gridmodifpresencepraticien_listeEtab" + Model.identifiantFicheCourante)
                  .Datasource(ds => ds.Json((IEnumerable<CodeLibelle>)Model.ListeEtablissementDisponible).Adaptor(AdaptorType.RemoteSaveAdaptor))
               .AllowScrolling(true)
               .AllowResizeToFit(true)
               .AllowRowDragAndDrop(true)
                       .RowDropSettings(d => d.DropTargetID("#gridmodifpresencepraticien" + Model.identifiantFicheCourante))
               .IsResponsive(true)
               .EnableResponsiveRow(true)
               .Locale("fr-FR")
               .Columns(col =>
               {
                   col.Field("libelle").HeaderText("Etablissements disponibles").TextAlign(TextAlign.Left).Width("160").AllowEditing(false).Add();
               }))
to this grid :

@(Html.EJ().Grid<PresencePraticien>("gridmodifpresencepraticien" + Model.identifiantFicheCourante)
                                       .Datasource(ds => ds.Json((IEnumerable<PresencePraticien>)Model.monPraticien.PRESENCES).Adaptor(AdaptorType.RemoteSaveAdaptor))
            .AllowScrolling(true)
            .AllowResizeToFit(true)
            .AllowResizing(true)
            .AllowRowDragAndDrop(true)
            .FilterSettings(fs => fs.FilterType(FilterType.Menu))
            .IsResponsive(true)
            .EnableResponsiveRow(true)
            .Locale("fr-FR")
                                    .RowDropSettings(d => d.RowDropMapper(Url.Action("EtablissementDropHandler"new { controller = "FichePraticien", area = "Praticiens" })))
            .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch); })
            .Columns(col =>
            {
                col.Field("ETABLISSEMENT.REF_ETABLISSEMENT").HeaderText("").Visible(true).Width("80").AllowEditing(false).Add();
                col.Field("ETABLISSEMENT.NOM_COURT").HeaderText("Etablissement").TextAlign(TextAlign.Left).Width("160").AllowEditing(false).Add();
                col.Field("STRUCTURES.LIBELLE").HeaderText("Structure").TextAlign(TextAlign.Left).Width("80").AllowEditing(true).Add();
                col.Field("FSE").HeaderText("FSE").TextAlign(TextAlign.Left).Width("20").AllowEditing(true).Add();
                col.Field("REMPLACANT.LIBELLE_PRATICIEN").HeaderText("Remplaçant").TextAlign(TextAlign.Left).Width("80").AllowEditing(true).Add();
                col.Field("ACTE_DEFAUT.REF_ACTE").HeaderText("Acte").TextAlign(TextAlign.Left).Width("80").AllowEditing(true).Add();
            }))
I create this function in my controller :

public ActionResult EtablissementDropHandler(List<CodeLibelle> added)
{
    List<PresencePraticien> result = new List<PresencePraticien>();
    foreach (CodeLibelle myEtab in added)
    {
        result.Add(new PresencePraticien(myEtab.code, myEtab.libelle, 0"""N"""""""));
    }
    return Json(result, JsonRequestBehavior.AllowGet);
}

but my row is blank in my second grid.

anyone have an idea ?

thanks,

1 Reply

SS Seeni Sakthi Kumar Seeni Raj Syncfusion Team January 18, 2017 12:56 PM UTC

Hi Cholet,  
 
We are able to reproduce the problem at our end only if the columns in the Destination Grid doesn’t hold the Columns that are dropping into them. For instance, if the Source Grid is having OrderID Column, the column must be present in the Destination Grid, otherwise it won’t show the records. Refer to the following screenshot, which shows the Destination Grid. 
 
In this, OrderID, CustomerID and EmployeeID shows the values for corresponding rows but the same row doesn’t hold values for the FSE, Remplacant and Acte. Since the dropped records are not holding the values these columns, the Grid shows them blank. So we suggest to ensure whether the dropped objects contains the rendered columns. 
 
We have also prepared a sample that can be downloaded from the following location. 
 
 
We have also noticed that your code example is missing the IsPrimaryKey for none of the columns. IsPrimaryKey is necessary for performing the Row Drag and Drop from/to the Grid. Refer to the following code example. 
 
@(Html.EJ().Grid<MVCSampleBrowser.Models.EditableOrder>("Grid1") 
                      .Datasource(ds => ds.Json((IEnumerable<MVCSampleBrowser.Models.EditableOrder>)Model).Adaptor(AdaptorType.RemoteSaveAdaptor)) 
                    . . . 
               .Columns(col => 
               { 
                   col.Field("OrderID").IsPrimaryKey(true).HeaderText("Order ID").TextAlign(TextAlign.Left).Width("160").AllowEditing(false).Add(); 
               })) 
 
@(Html.EJ().Grid<object>("Grid2") 
                .Datasource(ds => ds.Json((IEnumerable<object>)ViewBag.data1).Adaptor(AdaptorType.RemoteSaveAdaptor)) 
           . . . . 
            .AllowRowDragAndDrop(true) 
            .Columns(col => 
            { 
                col.Field("OrderID").IsPrimaryKey(true).HeaderText("OrderID").Visible(true).Width("80").AllowEditing(false).Add(); 
                     . .  
            }) 
) 
 
If you are still facing any problem, please share the following details to analyze your problem. 
 
1)      Screenshot for the problem 
2)      If possible modify the attached sample and replicate the issue. 
 
Regards, 
Seeni Sakthi Kumar S. 
 


Loader.
Up arrow icon