cancel
Showing results for 
Search instead for 
Did you mean: 

How to read invisible table row data in sapui5

rinku_sahu
Explorer
0 Kudos

Dear Friends,

In my scenario, my table is having more than 10 records, but visible rows are 10. So I am able to read the data upto 10th row.But from 11th  loop count, error is thrown as "Uncaught TypeError: Cannot read property 'getCells' of undefined"  in the below code.

var cells = rows[i].getCells();

Accepted Solutions (0)

Answers (2)

Answers (2)

rinku_sahu
Explorer
0 Kudos

Dear Kai,

I am sorry if I have mentioned anything wrong.

Also I have JavaScript Knowledge.I have mentioned my requirement clearly.Please read the question.

My code is here below:

for(var i=0;i<length;i++){

   

   // var cells = rows[i].getCells();

   

   var ctx=otab.getContextByIndex(i);

  

           if( ctx.getProperty("Belnr") != ''){

        //if(otab.getModel().getData().results[i].Belnr != ''){ 

    var invoice = ctx.getProperty("Belnr");                  //cells[0].getText();

    var delive  = ctx.getProperty("Delivery");              //cells[1].getText();

    var item    = ctx.getProperty("ItemNo");                //cells[2].getText();

    var Matnr   = ctx.getProperty("Matnr");                 //cells[3].getText();

    var SsdId   = ctx.getProperty("SsdId");                 //cells[5].getText();

    var total   = ctx.getProperty("Qty");                      //cells[6].getText();

    var rtotal  = ctx.getProperty("ReceivedQty");        //cells[7].getValue();

   child.push({Belnr:invoice,Delivery:delive,ItemNo:item,Matnr:Matnr,SsdId:SsdId,Qty:total,ReceivedQty:rtotal});

    }

My last field is editable,i.e. ReceivedQty. So I cannot take the model data directly.I just need to read the invisible rows in the page.

Kindly be specific and if u have answer Please share.

kai2015
Contributor
0 Kudos

Could you please place a sample working at JSBin?

You need to locate your model, which is bind to the table.

After this you do getData(9 on it, and then you have the current data object of your table.

Qualiture
Active Contributor
0 Kudos

As Kai and Dennis have mentioned, you should loop over the model data, and not the table rows/cells. If ReceivedQty is not part of your model data, then it should be made part of it

As a rule of thumb, there is never, and there will never be, a proper usecase for using the table.getRows() or table.getCells() methods. IMHO, these methods should be made deprecated or at least protected

kai2015
Contributor
0 Kudos

what about reading your model data?

Or why do you need to read the cells?

rinku_sahu
Explorer
0 Kudos

Hi Kai,

How to Read model data ? Please share some sample code.

I am not able to read the invisible rows in 2nd page or third page. Also if I am putting navigation mode as Scrollbar then also I am not able to read the invisible rows below the page.

former_member182862
Active Contributor
0 Kudos

Hi Rinku

What about oTable.getModel().getData() where oTable is your table control?

-D

rinku_sahu
Explorer
0 Kudos

Hello Dennis,

Thank you very much for your kind reply.

Can you give me some code, how I can extract the data from this model data ??

Regards,

kai2015
Contributor
0 Kudos

I'm sry but I think this is too much...

Learn JavaScript before asking after such simple tasks.

With getData() you will get the whole data object. Analyze it with developer tools and google for looping over such data objects. You'll find also a lot good stuff in this SCN space.

Just search a little bit.

Also please mark Dennis Seah's answer as correct.

Thank you.

former_member182862
Active Contributor
0 Kudos

But you already have the data from getData() 🙂

-D