Dandy Ling Kwong
Posts: 0
Joined: Sat Jan 10, 2015 9:06 am

How to map a grid to an array

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

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How to map a grid to an array

Hi,

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

Dandy Ling Kwong
Posts: 0
Joined: Sat Jan 10, 2015 9:06 am

How to map a grid to an array

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

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to map a grid to an array

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/...

Dandy Ling Kwong
Posts: 0
Joined: Sat Jan 10, 2015 9:06 am

How to map a grid to an array

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.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How to map a grid to an array

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...

Return to “Issues”