Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
joelajean
Posts: 123
Registered: ‎01-25-2010
My Device: Z10, Dev Alpha B & Bold 9900
My Carrier: Bell
Accepted Solution

Changing the GroupDataModel ItemGroup via QML / Javascript

Running into a smalll snag, which is taking to much resolution time... I'm trying to set the DataModel grouping via a QML javascript function.

function setDataModelGrouping(groupingTypeFull)
{
  myDataModel.setGrouping(groupingTypeFull ? ItemGrouping.ByFullValue : ItemGrouping.ByFirstChar )
}

When this is ran, the following error is generated...  Error: Unknown method parameter type: bb::cascades::ItemGrouping::Type

So basically, my QML file has no idea what ItemGrouping is.... but within a GroupDataModel, ItemGrouping is accesible...

 

MyModel 
{
  id: myDataModel

  // Sort the data items
  sortingKeys: ["column1", "column1"]

  // Set sort order to descending
  sortedAscending: false

  // Specify that headers should reflect the full value
  // of the sorting key property
  grouping: ItemGrouping.ByFullValue

  ...
}

 

Am I missing an import ?

 

Thanks

 

 

Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: Changing the GroupDataModel ItemGroup via QML / Javascript

This is because the function is out of scope try qualifying the two possible values with myDataModel as well.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
joelajean
Posts: 123
Registered: ‎01-25-2010
My Device: Z10, Dev Alpha B & Bold 9900
My Carrier: Bell

Re: Changing the GroupDataModel ItemGroup via QML / Javascript

You are saying, myDataModel.setGrouping() is out of scope ? If I call the GroupDataModel.setSortingKeys(), this method is not out of scope... According to the documentation both methods are public Public Functions Index.

https://developer.blackberry.com/native/reference/cascades/bb__cascades__groupdatamodel.html

function setDataModelGrouping(groupingTypeFull, groupByColumn, sortByColumn)
{
  myDataModel.setSortingKeys([groupByColumn, sortByColumn])
  //myDataModel.setGrouping(groupingTypeFull ? ItemGrouping.ByFullValue : ItemGrouping.ByFirstChar )
}

From the error, it's the ItemGrouping enum type that is failing... According to the documentation, this one is also public...

https://developer.blackberry.com/native/reference/cascades/bb__cascades__itemgrouping.html#enum-type

Please use plain text.
Developer
BBSJdev
Posts: 5,948
Registered: ‎07-05-2012
My Device: Playbook, Z10 LE, Dev Alpha C
My Carrier: Orange

Re: Changing the GroupDataModel ItemGroup via QML / Javascript

[ Edited ]

No I'm saying that the whole javascript function is out of scope, you qualify the myDataModel object's function call (myDataModel.setGrouping) to access it but you are not doing the same for ItemGrouping.ByFullValue and ItemGrouping.ByFirstChar, so therefore these cannot be found.


If you've been helped click on Like Button, if you've been saved buy the app. :smileyhappy:

Developer of stokLocker, Sympatico and Super Sentences.
Please use plain text.
Developer
joelajean
Posts: 123
Registered: ‎01-25-2010
My Device: Z10, Dev Alpha B & Bold 9900
My Carrier: Bell

Re: Changing the GroupDataModel ItemGroup via QML / Javascript

Are you saying it should be... coze that does not seem to work either.

function setDataModelGrouping(groupingTypeFull, groupByColumn, sortByColumn)
{
  myDataModel.setSortingKeys([groupByColumn, sortByColumn])
  myDataModel.setGrouping(groupingTypeFull ? myDataModel.ItemGrouping.ByFullValue : myDataModel.ItemGrouping.ByFirstChar )
}
Please use plain text.
Developer
joelajean
Posts: 123
Registered: ‎01-25-2010
My Device: Z10, Dev Alpha B & Bold 9900
My Carrier: Bell

Re: Changing the GroupDataModel ItemGroup via QML / Javascript

Got it working by creating a setMyDataModelGrouping method within myDataModel class. Not the best solution but enough time spent investigating this issue...

I'm still puzzled has to why the GroupDataModel.setGrouping() method keep on failing from javascript... According to the documentation it's a public method... therefore should be invokable from qml / js.

https://developer.blackberry.com/native/reference/cascades/bb__cascades__groupdatamodel.html#functio...

Please use plain text.