Let's follow up this discussion at the Neptune Community

(this forum will be kept in read-only mode)

Edit row of Table

Hi, 

I've a Table element generated by an ABAP method. Inside a column there is an editable field that should drive values of all cells of the same row.

Could you explain me how can I edit all cells of the same row at onChange event of editable field? I hope it is quite clear what I need...I've attached an image of my sitauation.

Thank you and regards


Alessandro 

png
(41.3 KB)

Hi Ole, 


I have a similar requirement...The solution is working fine when I am trying to update one record but it does not work if I have more than 1 record to update (For ex- if I am trying to update two records in the table, botth the records in the table gets updated but with the last change - how to overcome this?). 


Also what if my key field is a combination of Date and Time fields then how can I pass the combination of both the fields as key field?


Regards,

Rahul.

Hi Alessandro,


Were you able to resolve your problem? I have the same problem as you had and I am unable to find a solution.


Please help me if you were able to solve your issue.


Thanks

Amit

Hi Amit 


Here is an example. I hope this is clearly enough explained. If you need further help, please let me know your problem, printscreen from the designer etc.


ModelData.Update fields:

  1. FieldName of you object with binded model (in the designer)
  2. FieldName of your key in the model
  3. FieldValue of your key in the model
  4. New Data (workarea of the internal table)

 

// Get the model for OrderHeader - Structure (Workarea)
dataHead = modelpageOrder.oData();

// Change Data
dataHead.BSTNK = "Some new Data";

// Update Header - Table
ModelData.Update(tabOrder,"VBELN",dataHead.VBELN,dataHead);

 

Regards

Ole Andre 


Hello Ole Andre,


I tried as per your advise but still no luck. I am attaching the details in the document.


Please take a look and advise how to proceed.


Thanks,

Amit

docx

Hi Rahul,


please set your sap.m.Table object property 'mode' to MultiSelect.

Then use the following code-snippet in order to retrieve all selected table entries:


// Replace yourTable with Table/List ID

// Replace yourField with Field ID


var itemsSelected = yourTable.getSelectedItems();


for (i=0; i<itemsSelected.length; i++){

var item = itemsSelected[i];

var context = item.getBindingContext();

var value = context.getProperty("yourField");


// Do something


}


Neptune recommends to provide a single surrogate key field, could also be a concatination of fields. All Neptune data methods are based on a single key field.


Best regards

Christoph

Hi Ole,


Thanks for your reply. I am already using something similar for my requirement :

I have the below code in the Value HelpRequest event of the Inputfield :


objSelected=this;

listABWGR.open();


And the below code in the Confirm event of the Select Dialog :


var selectedItem = oEvent.getParameter("selectedItem");

var context = selectedItem.getBindingContext();

var value = context.getProperty("TEXT");


var context_new = objSelected.getBindingContext();

var datahead = modeloPage_HR.oData; //Structure to update my back end table

datahead.PDSNR = context_new.getProperty("PDSNR");

datahead.SATZA = context_new.getProperty("SATZA");

datahead.ABWGR_TEXT = value;

datahead.ENABLED = Boolean(true);

datahead.CHANGED = "X";

// Add Data

ModelData.Update(oHR2011Table,"PDSNR",datahead.PDSNR,datahead);

objSelected.setValue(value);


This code works absolutely fine when I am changing data in 1 of the input field of the table and pressing update button, but when I change 2 of the input fields and then press update both the records in the back end are update but with the values of the 2nd record. I am not sure why?


I hope I was able to explain the issue.


Regards,

Rahul.

Hi Ole,


I want to get the values from an table cell and delete the cell in a table using delete icon .

how do i get the values of a particular row and delete it from the table ? Please give me a clue to write the JavaScript.

Hi Christoph,


Thanks for your reply..however, in my solution the user doesn't have to select anything. Please see the attached screenshot. Here, the user can change one or more values in the Input field from the f4 help. And then click on a button, my requirement is to just change these values to the backend table. Also the problem I am facing using the ModelData .update method is that my keyfield is a combination of the date and time fields. So I am not sure how to handle this.


I hope I am clear. 


Thanks a lot for your help.


Regards,

Rahul.

jpg
(104 KB)

I have now been able to resolve the issue myself. Thanks a lot for your help.

Hi Amit,


Were you able to resolve your issue? 


Regards,

Rahul.

Hi Alessandro


I think the solution is to update the model data. When selecting the partner, on the OnChange event, you need to update the modeldata for City/Address etc.


and maybe a refresh to display the changed data: modelPartnerList.refresh();


Regards

Ole Andre 

Hi Rahul


If you are using an inputfield and ValueHelpRequest you can do like this:


On the event: valueHelpRequest


 

// Set Object
var context = oEvent.oSource.getBindingContext();
objSelect = (context.getObject());

// Open Dialog
listMaterial.open();

 

The objSelected is a global javascript variable. This will now contain the record you currently pressed on.


On the confirm/select event you can access the objSelected and change the data content. This example uses an selectDialog and the conform event:


  

// Single Select
var selectedItem = oEvent.getParameter("selectedItem");
var context = selectedItem.getBindingContext();
var matnr = context.getProperty("MATNR");

// Set New Data
objSelect.MATNR = matnr;
 

 

Regards

Ole Andre  

thank you for your reply. I was already working with model data, but if I try to update modelPartnerList, I'll update the entire table instead of the line I need.

Could you give me an example how I've to update the current row?


Thank you and regards


Alessandro

Hi Alessandro


I would use the ModelData.Update method to update the correct row.


More information on the Offline ModelData object:

https://template.neptune-software.com/neptune/sdk/explored#doc00163EDC99661ED4B4C34B6CE4E56F06


Regards

Ole Andre 

Login or Signup to post a comment