Getting data in MyModel.getFirstRow() but not in MyModel.data

  • 2
  • Question
  • Updated 3 years ago
  • Answered
I am getting data in MyModel.getFirstRow() but not getting data in MyModel.data.
Any can help me why cannot get data MyModel.data?
Photo of Rohit Vakhariya

Rohit Vakhariya

  • 1,054 Points 1k badge 2x thumb

Posted 4 years ago

  • 2
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Make sure you are using the following syntax   skuid.model.getModel('MyModel').data
Photo of Rohit Vakhariya

Rohit Vakhariya

  • 1,054 Points 1k badge 2x thumb
Can you provide way to calculate number  of row in data?
I am using below way is it correct?
var Agcontact=skuid.model.getModel("Agcontact");
var length=Agcontact.data.length;
(Edited)
Photo of Rohit Vakhariya

Rohit Vakhariya

  • 1,054 Points 1k badge 2x thumb
I am using same code.

var MyModel=skuid.model.getModel('MyModel');
  
MyModel.getFirstRow();

and

MyModel.data;
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
To get the number of rows in a Model:

MyModel.getRows().length

Getting the first row in a Model can be done 3 ways (assuming that a Model has at least one row):

1. MyModel.getFirstRow()
2. MyModel.data[0]
3. MyModel.getRows()[0]
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Quick note for the documentation folks: Please include getRows() as a method on the skuid.model.Model document. Thanks!
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Matt, this is being done right now, thanks!
Photo of Rohit Vakhariya

Rohit Vakhariya

  • 1,054 Points 1k badge 2x thumb
I am using below code in my java script for activate condition. But This code is not working properly.It is always fetch old data(The data which i have last saved.)

var LastNamecondition = Agcontact.getConditionByName('LastName');    Agcontact.setCondition(LastNamecondition,'Vakhariya',true);
 Agcontact.updateData();