This is a migrated thread and some comments may be shown as answers.

How To Pass a list of objects into the create() ?!

1 Answer 502 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
K.Ramadan
Top achievements
Rank 2
Veteran
K.Ramadan asked on 10 Jun 2020, 02:07 PM

Hello,

I'm trying to send selected values (from grid) but the creation is coming from the scheduler ..

I saved the values in a global variable and i tried to this ..

 

THIS is the ActionMethod in the Controller :

public ActionResult Cal_Create ([DataSourceRequest]DataSourceRequest request, KommunikationViewModel kommunikation,string[] SIDMITARBEITER, string[] SIDPERSONEN, List<UserViewModel> MITARBEITER_OBJ)
        {}

 

 

Create() method from my scheduler :

.Create(create => create.Action("Cal_Create""Home").Data("pass_Einladung_Miatarbeiter_Personen"))

 

PS : i copy pasted only the create() so that i don't need to copy my whole scheduler !

 

 

This is the additional function that attached to the create() function :

 function pass_Einladung_Miatarbeiter_Personen() {
                console.log("passing the array");
                console.log(Global_Array_Grid_mitarbeiter_Selected);
                var Mitarbeiter_Grids_IDs = new Array();
                var Personen_Grids_IDs = new Array();
 
                Global_Array_Grid_mitarbeiter_Selected.forEach(function (item, index) {
                    var SID_MITARBEITER_AUS_GLOBAL = item.Sid_mitarbeiter;
                    Mitarbeiter_Grids_IDs.push(SID_MITARBEITER_AUS_GLOBAL);
                });
 
                Global_Array_Grid_person_Selected.forEach(function (item, index) {
                    var SID_Personen_AUS_GLOBAL = item.Sid_personen;
                    Personen_Grids_IDs.push(SID_Personen_AUS_GLOBAL);
                });
                var xxoop = JSON.stringify(Global_Array_Grid_mitarbeiter_Selected);
                return {
                    SIDMITARBEITER: Mitarbeiter_Grids_IDs,
                    SIDPERSONEN: Personen_Grids_IDs,
                    MITARBEITER_OBJ: xxoop}
            }

 

// so i took one value from the object and put it into an array .. and that worked like a charm .. so defining a string[] as a parameter in the create ActionMethod .. did not make any problem .. but defining a List of object (like the code snippet) or a list of Objects .. is giving always NULL ! and it's not NULL because I'm console logging this variable in almost every step .. to follow if kendo delete the values after some action .. but no .. it's there .. but not getting sent to the ActionMethod ..

Thanks in Advance ..

1 Answer, 1 is accepted

Sort by
0
Aleksandar
Telerik team
answered on 12 Jun 2020, 01:40 PM

Hello,

Based on the provided details it appears the issue is related to the data serialization, but not actually to the passing of data vie the data handler function. However, the provided details are not enough to be certain what the issue might be caused by.

If you inspect the Create action of the Scheduler you will notice that the data is passed to the action method as FormData. When using FormData it is not possible to append arrays and/or complex objects. You need to append key/value pairs for each property. Furthermore, when a list of objects is expected a particular naming convention needs to be followed. You can read more on passing complex objects and list of objects in the following SO thread:

https://stackoverflow.com/questions/54736887/sending-multiple-json-lists-and-image-in-formdata-to-c-sharp

Regards,
Aleksandar
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
Tags
Scheduler
Asked by
K.Ramadan
Top achievements
Rank 2
Veteran
Answers by
Aleksandar
Telerik team
Share this question
or