Page 1 of 1

How to map a grid to an array

Posted: Wed May 27, 2015 7:20 pm
by Dandy Ling Kwong

I have a grid which contains elements populated from a list. How do I update a local storage array with the elements from the grid? I tried the following mapping, but it only map one element to the storage array, instead of all elements on the grid.

Image


How to map a grid to an array

Posted: Wed May 27, 2015 8:37 pm
by Alena Prykhodko

Hi,

Please see how to map grid here https://devcenter.appery.io/documenta...


How to map a grid to an array

Posted: Thu May 28, 2015 6:11 am
by Dandy Ling Kwong

Hi Alena,

The examples are all for array to grid. That I can do.

However, it doesn't work when I try to map grid to array, as shown below Image


How to map a grid to an array

Posted: Thu May 28, 2015 1:19 pm
by Serhii Kulibaba

Hello Dandy,

You are right it is not allowed create mapping from grid to array (because grid is not array). Could you tell why do you need such mapping? Do you need write one more array item to the storage variable? Please follow this topic: https://getsatisfaction.com/apperyio/...


How to map a grid to an array

Posted: Sun May 31, 2015 3:00 pm
by Dandy Ling Kwong

I have managed to do this using jQuery .each() function as I noticed each grid is essentially a duplicate of the parent grid and has similar naming.

Code: Select all

$("[id^='patientProfile_mobilegrid_74_']").each(function(){ 
     var diag={ 
         diagnosis  : $(this).find("[name='mobiletextinput_70']").val(), 
         consultant  : $(this).find("[name='mobiletextinput_72']").val(), 
         dateOfReferral : $(this).find("[name='mobiledatepicker_55']").find('input').val() 
     }; 
     storagePush("beforeSendPatientDiagnosis", diag); 
 }); 

To Sergiy:

The reason I need this is that I have an array of items from the database that is listed out as text edit using the grid. This list is editable, and once it is edited, I want to save it back to the database. Hence, I need to map it from the grid to the array in the database.

Currently, how I do this is by pushing the content of the list to the storage variable using jQuery's .each() as shown above, then I map the storage variable to the database.


How to map a grid to an array

Posted: Tue Jun 02, 2015 8:56 pm
by Serhii Kulibaba

Please write item id as grid HTML-attribute and read it when you need change value in DB. One item per one request. Here you can find an example: https://devcenter.appery.io/documenta...