onTriggered retail Info (LISTVIEW)
Hello
Sorry to ask again
I want to show the details of my promo
It's my main QML
NavigationPane { id : nav1 onPopTransitionEnded: page.destroy() Page { Container { Header{ title: "Promo" } ListView { id: listViewDemo dataModel: GroupDataModel { id : prm1 grouping: ItemGrouping.None } listItemComponents: [ ListItemComponent { type: "promo" Container { layout: StackLayout { orientation: LayoutOrientation.LeftToRight } WebView { preferredWidth: 150 preferredHeight: 90 verticalAlignment: VerticalAlignment.Top url : ListItemData["ImageLink"] } StandardListItem { title: ListItemData["promoID"] + "." + ListItemData["Title"] description: ListItemData["Description"] leftMargin: 30 verticalAlignment: VerticalAlignment.Center } } } ] function itemType(data, indexPath) { return "promo"; } onTriggered: { if(indexPath!=0){ var promo = prm1.data(indexPath); var promodetail = promocontent.createObject(); promodetail.promo = promo; nav1.push(promocontent); } } } } } } attachedObjects: [ DataSource { id: serviceDataSource source: "http://www.rws.rajaspot.com/rs_promoclient.php" type: DataSourceType.Json onDataLoaded: { listViewDemo.dataModel.insertList(data.promo_info) } }, ComponentDefinition { id : promocontent source : "PromoContent.qml" } ] onCreationCompleted: { serviceDataSource.load(); }
It's my promodetail
Page { property variant promo; Container { id: container1 verticalAlignment: VerticalAlignment.Center horizontalAlignment: HorizontalAlignment.Center topPadding: 50 WebView { id : imageview horizontalAlignment: HorizontalAlignment.Center url: promo["ImageLink"] preferredWidth: 400 preferredHeight: 400 } Label { id:label1 textStyle.base: SystemDefaults.TextStyles.BigText horizontalAlignment: HorizontalAlignment.Center text:promo["Title"] } Label { id:label2 textStyle.base: SystemDefaults.TextStyles.SubtitleText horizontalAlignment: HorizontalAlignment.Center text:promo["Description"] } } }
the following error message are
url: promo["ImageLink"]
text:promo["Title"]
text:promo["Description"]
He can't call my main.qml
any suggestion?
Thank you
In some cases, your promo property can be "undefined" after you press page. Because it is not yet assigned. You can avoid this if you check the property on your page.
For example:
Page{ property variant promo: null Container{ layout: DockLayout{} leftPadding: 20 rightPadding: 20 topPadding: 20 Label{ id: label horizontalAligment: HorizontalAligment.Center /* In some cases will be the text empty. Because promo property is not yet assigned*/ text: promo.Description } } }
-------------------------------------------------
See the simple example. You have two options to avoid ownership promo "undefined".
1. replace the text property of the label with this
text: promo? Promo. Description:
2. signal property promo label definition
onPromoChanged: if (promo) label.text = promo. Description
My English is bad, so I hope you understand what I mean. Maybe someone who has good English can specify my 'answer '.
EDIT:
You can also find 'Data passing between the QML pages' for more information
Tags: BlackBerry Developers
Similar Questions
-
To access the instance of the ListView onTriggered event ListItemComponent
Hello
I'm pulling out my hair with this!
I have a ListItemComponent in my ListView, and I want to access the component instance in the onTriggered of my ListView. I have the row, but I can't work on how to find the actual view.
Simple example:
{To ListView
ID: myListView
dataModel: myDataModel
layout: {FlowListLayout}
listItemComponents:]
{ListItemComponent}
type: 'imageItem.
{GalleryImages}
}]
onTriggered: {}
It's easy
var point = dataModel.data (row);
BUT HOW to ACCESS the GalleryImages instance for the row?
}
...
I'm sure it's really simple, but have been hitting my head against it for 2 days!
C
https://developer.BlackBerry.com/Cascades/reference/bb__cascades__listview.html
your variable 'point' reference the underlying data in the datamodel - it does not refer to the list Visual element (i.e. ListItemComponent).
You need to move your manager in the ListItemComponent - and probably change in notecard or anything that supports your component of GalleryImages.
-
Mark the selected item in a listview
Hello experts,
So, I need to show a selected list item by placing a checkmark next to him (into the cell). What a cell can be selected. So does anyone have a solution that can be shared? Or some advise how this can be done properly. I would be very grateful.
Hello everyone.
I did the following. In onTriggered in a listview control, I've added these 2 lines:
clearSelection(); select(indexPath, true);
That's all.
-
Highlight the item selected in the ListView
Hello guys,.
I have a list view and you want to highlight the element select when I click on it, for all clicked items.Thank you.
esam_tec wrote:
Hello guys,.
I have a list view and you want to highlight the element select when I click on it, for all clicked items.Thank you.
There are different ways to do
eg.:
in your container of ListItem:
background: ListItem.selected || ListItem.active ? Color.Magenta : Color.Transparent
in your onTriggered of the ListView:
// select line myListView.select(indexPath, true)
Remember, if your work has been done:
// clear the selection myListView.clearSelection()
-
Hello
I have a ListView with a learn a more clickable label at the bottom right of the list item. However, when I click on learning more label ListView consumes also to the touch...
ListView { listItemComponents: [ ListItemComponent { Container { Label: { text: "Description" } Label: { id: label2 onTouch: { if (event.isUp()) { //Child Label do Something //Point A } } } } } ] onTriggered: { //Point B delegate.itemSelected(indexPath); } }
My problem is although label2 is clicked the touch event is also handled by the ListView method onTriggered. Does anyone know I can keep the ListView of the manipulation to the touch even when label2 manages to touch?
Thank you
Hello
You can check this code it will help for you. I think that this will solve your problem.
import bb.cascades 1.0 Page { Container { ListView { id: listview dataModel: GroupDataModel { grouping: ItemGrouping.None } listItemComponents: [ ListItemComponent { type: "item" Container { id: cont preferredWidth: 500 preferredHeight: 100 background: Color.Gray Label { text: ListItemData.title } Label { text: ListItemData.description touchBehaviors: TouchBehavior { eventReactions: TouchReaction { eventType: TouchType.Down phase: PropagationPhase.AtTarget response: TouchResponse.StartTracking } } onTouch: { if (event.propagationPhase == PropagationPhase.AtTarget) { if (event.isDown()) { console.log("label at target phase"); } } } } } } ] onTriggered: { console.debug("listview triggered"); } onCreationCompleted: { for (var i = 0; i < 5; i ++) listview.dataModel.insert({ "description": "description", "title": "listitem" }); } } } }
If you touch the first label it will trigger the display of the list and if you touch the second label does not trigger the ListView.
-
How to change the layout of the listview in javascript?
I need show listview two different data schemas.
can I change the listview.layout of js?
my code is like this:
{Page 1
function aaa (type) {}
if(type=="List")
listschema = StackListLayout (); new StackListLayout();
on the other
listschema = new GridListLayout();
listschema.cellAspectRatio = 3 / 4;
listschema.horizontalCellSpacing = 5;
listschema.verticalCellSpacing = 5;
listschema.columnCount = 2;}
{page 2
property alias listschema lista.layout
....
ListView {...}
....
}
Thank you...
Hello
You can set the layout for the listview dynamically from javascript by doing like this.
Page { Container { ListView { id: listview dataModel: GroupDataModel { grouping: ItemGrouping.None } /*layout: StackListLayout { orientation: LayoutOrientation.LeftToRight }*/ listItemComponents: [ ListItemComponent { type: "item" Container { id: cont preferredWidth: 500 preferredHeight: 100 background: Color.Gray Label { text: ListItemData.title } Label { text: ListItemData.description } } } ] onTriggered: { console.debug("listview triggered"); } onCreationCompleted: { listview.layout = layout } } } attachedObjects: [ /*StackListLayout { id:layout orientation: LayoutOrientation.LeftToRight }*/ GridListLayout { id: layout columnCount: 2 } ] }
Kind regards
Naresh Kodumuri.
-
I'm passing pointers for instance in one of my classes around as an element of a QVariantMap. 98% of the time it works well, while 2% is killing me. Sometimes when I extracted the pointer elsewhere in my app it comes out as NULL rather than this pointer valid that was on there.
Here's an example of how to get the pointer in the QVariantMap:
MyClass* myClassPtr; QVariantMap map; myClassPtr = &myClassInstance; map["title"] = "Pointer to my class";Q_ASSERT(myClassPtr); map["myClass"] = QVariant::fromValue( myClassPtr );Q_ASSERT(map["settings"].value
()); Once the 'map' is filled with other values too happening around in the application by various means, such as a signal when the user does something. In contrast, when I need the pointer back, I do the following:
MyClass* myClassPtr = map["settings"].value
();Q_ASSERT(myClassPtr); As I said, 98% of the time this works as expected, but the remaining time the pointer spell back as NULL, which obviously has critical implications when I try to call functions of the object of it. Strangely, the "title" element always comes out correctly even when the pointer is not. I know that the pointer is lost in transit because the first and the second fire Q_ASSERTs never, even when the third. Either way, I am trying to retrieve the pointer to the same place in the code every time. It will work fine 10, 20, 40 times in a row, then next time... boom!
I can not understand what is happening here.
Update: on the off-chance that it might be useful, I'll explain how the QVariantMap happening around. Only the first block of code is a class that generates a QList
and use it to fill a GroupDataModel. The second block is a function that is triggered when the user clicks on one of the items in the ListView that uses this GroupDataModel, and it gets the path of the index of the item that the user has typed as a parameter. To develop this second block:
QVariantMap map = dataModel->data( indexPath ).value
(); QString title = map["title"].toString(); myClass* myClassPtr = map["settings"].value (); Q_ASSERT(myClassPtr); AsI said before "title" comes out correctly, and usually 'settings', but not always. Maybe someone notices something wrong with this additional detail.
UPDATE: Turns out that I was running a red herring, because it has nothing to do with QVariantMap. After weeks of having my app "randomly" close last night, I realized that there was a reason after all and I learned something new about ListView.
What I didn't know, is that numbers of ListView by triggered() report not ONLY when you tap an item in the list, but also when you tap on a header. My articles are quite large while my headers are very narrow. What was going on, it was that a few times out of a hundred, I got a little sloppy typing element and hit header instead. This triggered a function which should receive a path index pointing to a QVariantMap of the datamodel that had been filled with the item "settings". When I typed in the header error, it was not to do the QVariantMap with the 'settings' so when I cast to MyClass * liquidation was always NULL.
What made it particularly difficult to identify, it is that I'm very rarely enough botched hit header by mistake, and there was no indication that I had done, so I thought the app was going to die when I was the ListView element you tapoterez normally. I didn't know that ListView sends a signal triggered() for valves header too.
I fixed it by checking the length of row in the slot in onTriggered of the ListView. If the length is two then an item has been exploited, so I call the function. However, if the length is one then this is a header instead, so I did nothing.
-
DeleteActionItem of ContextMenu problem
I'm stuck trying to delete a record after that I chose, by using a contextmenu. I've been able to get the deletion of work if I type the string customerID element I want to remove, either by a sheet in the code.
Here is my code:
Container { contextActions: [ ActionSet { title: ListItemData.name actions: [ DeleteActionItem { title: qsTr("Delete") imageSource: "asset:///images/delete.png" attachedObjects: [ SystemToast { id: deleteToast body: "Item Deleted" } ] onTriggered: { _app.deleteObject(listView.selectedItemID); console.log("deleteObject") deleteToast.show() } } ] } ] ListView { id: listView property string selectedItemID dataModel: _app.dataModel listItemComponents:[ ListItemComponent { type: "item" StandardListItem { title: ListItemData.name description: ListItemData.description status: ListItemData.customerID } } ] onTriggered: { clearSelection() select(indexPath) locationInvoker.locationLatitude = dataModel.data(indexPath).lat locationInvoker.locationLongitude = dataModel.data(indexPath).lon routeInvoker.endLatitude = dataModel.data(indexPath).lat routeInvoker.endLongitude = dataModel.data(indexPath).lon selectedItemID = dataModel.data(indexPath).customerID } } }
DeleteActionItem if I change _app.deleteObject (listView.selectedItemID) with a number ('10') quotes the record with customerID 10 actually gets deleted. However, when I change for the variable it tells me the ID of the object was not found, so I'm passing obviously not correct information. Any suggestions?
In addition, as a context menu, the context menu does not appear the ListeItemData.name is just empty. I wish that the context menu to display the list item selected in my application that I am about to delete. I think that these two issues are the same problem.
Thanks in advance.
Please see the code as amended below. It has not been tested and may require a few tweaks. I scored my changes with "/ / 1", "/ / 2", "/ / 3", "/ / 4".»»»
Also, I suggest to pass the statement SystemToast to top-level container, otherwise multiple instances will be created. In this case you will need to reference using a helper function (similar to getApp()), because it will be not visible directly from ListItemComponent. But it should work "like what" too.
Container { ListView { function getApp() { // 1 return _app } id: listView property string selectedItemID dataModel: _app.dataModel listItemComponents: [ // 2 ListItemComponent { type: "item" StandardListItem { id: rootItem // 3 title: ListItemData.name description: ListItemData.description status: ListItemData.customerID contextActions: [ ActionSet { title: ListItemData.name actions: [ DeleteActionItem { title: qsTr("Delete") imageSource: "asset:///images/delete.png" attachedObjects: [ SystemToast { id: deleteToast body: "Item Deleted" } ] onTriggered: { rootItem.ListItem.view.getApp().deleteObject(rootItem.ListItem.indexPath); // 4 console.log("deleteObject") deleteToast.show() } } ] } ] } } ]
-
topic of onTriggered in listview
Hello
I need to
I have a listview on the list of all my image
It's my listitemcomponent:
WebView { id :web preferredWidth: 200 preferredHeight: 150 url : ListItemData.imageThumbnailURL }
onTriggered: { clearSelection() select(indexPath) var item = dataModel.data(indexPath) if (item){ //What should i do here? } }
It's my webview that the bigone
WebView{ id : itemimage //url : image ? image["imageThumbnailURL"] : "" }
It is what should show
the small images located on the right side is my: listitemcomponent
the big picture which is on the left side is WebView
If I hit one of my list on the right, it will automatically go to enlarge
What should I do in 'onTriggered '?
Thank you
You can change the URL used by your WebView something like this:
itemimage.url = item.whateverVariableHoldsTheURL
-
ListView Access of ListItemComponent context action onTriggered model
Consider following piece of code:
ListView { id: listView dataModel: model listItemComponents: ListItemComponent { content: StandardListItem { title: ListItemData.name contextActions: ActionSet { actions: ActionItem { title: "Delete" onTriggered: { //ListItem.view.model .... doesn't work } } } } } } }
When the user chooses to delete a line, I would like to access the listview model and remove the line given. But I can't get my hands on the model (as it is now defined as attached property).
Docs say:
ListItem.view - The ListView in which this item is visible. The item is in a context separate from the ListView, so any symbols from the ListView context that are to be accessible from items must be placed as dynamic properties on the ListView
But to be honest I don't understand what I need to do to make it work (ie. have access to the parent listView.
Any help would be greatly appreciated.
Oh, I would do this without falling back into C++ code. I know how to solve this problem with c ++.
Thank you
You must reference it in your ListItemComponent ListItem:
myItem.ListItem.view.dataModel
-
ListView onTriggered event to push a new page
Currently, I started to learn and develop applications for bb10. I saw troubled when wants to push a new page when click the item in the listview.
ListView { dataModel: XmlDataModel { source: "model.xml" } listItemComponents: [ ListItemComponent { type: "listItem" StandardListItem { title: ListItemData.title description: ListItemData.subtitle status: ListItemData.status } } ] onTriggered: { var new_page = nextpage.createObject(); navigationPane.push(new_page); } attachedObjects: [ ComponentDefinition { id: nextpage source: "newqml.qml" } ] }
The code that I use, I expect to get to the newqml.qml, then click on any point on the listview however is not doing. How can I change the code to obtain the result.
and if I want it open different page each item in listview how does?
Thanks in advance.
Hello
I'm new on this, but I have a tip that could help: create a new project, select stunts, then on the models page, select ListView.
This will automatically create a default list that automatically connects your article to an ItemPage.qml of a second!
-
onTrigger go to the last line of the ListView
Hello
The above is possible? I have a list of RSS, I would like to know is there a way I can do onTrigger go to the last column in my listView.
Thank you
How can I get the number of items in dataModel?
It depends on dataModel type you use, see the documentation for the corresponding classes.
For ArrayDataModel and GroupDataModel:
var n = dataModel.size () / / or dataModel.childCount (0) - number of students in first section
Row is a table where the first number is the section and the second is stored in the section.
Something like this should work:
var dataModelSize = listViewId.dataModel.size(); // or listViewId.dataModel.childCount(0)if (dataModelSize > 0) { var lastRowNumber = dataModelSize - 1 listViewId.scrollToItem([0, lastRowNumber], ScrollAnimation.Default); }
Replace the listViewId with the id of your ListView.
If this does not work, please copy - paste your current code and errors that appear in the papers (as appropriate).
-
Action on multiple selection ListView onTriggered
Hi, I have a listview with multiSelectHandler impleted and so can select multiple items.
I'm having a problem on how to perform the action on these several items though.
Documentation, http://developer.blackberry.com/cascades/documentation/ui/lists/list_view_selection.html, does not show how to perform the action when several items to the listview are selected.
Does anyone know how to make measurements on multiple items? i.e. remove it from the list, get the text of each article, changes to the user interface, etc.
Hello
Have you seen Battambang sample? I remember well, it can perform operations on several list items:
https://github.com/BlackBerry/Cascades-samples/tree/master/bucketlist
-
using a drop-down list to power a listview
I try to get a drop-down list selection (newOption) to fuel a sql query to get more information in a listview. The drop down menu works ok, but the list is empty. My dosent sql query recognize newOption and therefore does not feed listview.
Please could you help me with the query syntax. Thank you.
My code is below. If I replace '+' "' + newOption +" ' with a sql table entry, IE 'the cradle', then the listview works very well.
import bb.cascades 1.2
import bb.data 1.0
import com.apiary.data 1.0{Page}
ID: infoPage{Of container
{Label
text: "Info Page".
verticalAlignment: VerticalAlignment.Center
horizontalAlignment: P
}{Drop-down list
ID: dropdown
}{To ListView
ID: apiaryList
dataModel: dataModellistItemComponents:]
{ListItemComponent}
type: 'point '.
{StandardListItem}
ID: apiaryItemTitle: ListItemData.apiary_name
Description: ListItemData.apiary_location
status: ListItemData.apiary_id
}
} / / end of ListItemComponent
]onTriggered: {}
}
}
attachedObjects:]{GroupDataModel}
ID: dataModel2
},
{ComponentDefinition}
ID: optionFactory
Option {}
}
},
DataSource {}
ID: dataSource2
Source: "sql/hood_apiary.db.query: "SELECT * FROM Apiary ORDER BY apiary_name".
onDataLoaded: {}
dataModel2.insertList (data);Now, this is going to populate the drop-down list while reiterating each
the query data and adding one by one to the drop-down list
using the optionFactory component to dynamically add definition
New Options for the drop-down list
for (var i = 0; i)< data.length;="">
{
Create new Option
var newOption = optionFactory.createObject)Set the text of the Option categoryfield (title of the drop-down list)
newOption.text = data .apiary_name [i]
Console.log ("newoption.text =" + newOption.text);Add the Option in the drop-down list
DropDown.Add (newOption);
}
}
},{GroupDataModel}
ID: dataModel
},
DataSource {}
ID: dataSource
Source: "sql/hood_apiary.db.string newOption property
query: "SELECT * FROM Apiary, hive where apiaries.» [apiary_name] = ' "+ newOption +" ' AND Apiary. [apiary_id] = hive. [apiary_id] AND the hive. [apiary_id] is not null ORDER BY hive_id DESC'
onDataLoaded: {}
dataModel.insertList (data);
}
}
]onCreationCompleted: {}
When the display of the list has been created, load the data into the listview
and the drop-down list.
dataSource.load ();
dataSource2.load ();
}
}}
Hello Simon
Thank you very much for your help, you have solved a problem I had for centuries.
{Drop-down list
ID: apiarydropdown
Title: 'select the Apiary.
onSelectedIndexChanged: {}
var dropvalue = apiarydropdown.at ("apiarydropdown.selectedIndex") .text;
Console.log ("dropvalue has been changed to" + dropvalue);
Console.log ("selectedIndex was changed to" + selectedIndex);
dataSource.query = "SELECT * FROM Apiary, hive where apiaries.» [apiary_name] = ' "+ dropvalue +" ' AND Apiary. [apiary_id] = hive. [apiary_id] AND the hive. [apiary_id] is not null ORDER BY hive_id DESC'
dataModel.clear () / / clears all previous listview view
dataSource.load () / / load listview
}
} -
point to row in the ListView multiselect
Once again, the lack of documentation around annoys me no. where to go so I hope someone can enlighten us
I do it s simple list multiple selection on a customized ListView, by trial/error, I get a row on the
{ActionItem}
...
var temp = my_list.selectionList ();
Temp [0] is the 1stevel of row to the ELT in the list, how the hell I get the actual data for the current item?
(Works dataModel.data(temp[0]).list_fld onSelectionChanged but not onTriggered, I saw a strange)
listView = parent.parent.parent, but that one does not work either. The bucket sample did not help either.
Pretty frustrating is repeat the old song now... How you want devs to come when you play mysterious and not document this? Some of the ad will be would be good if you get a cut of the tech writers and start matching section. This list seems to be powerful but useless if we must spend hours of trial/error to understand how it works.
These forums are supported by the community, with many other developers like you (i.e., people who do not work for BlackBerry) try to help each other. It does not help us help when we have to read through stuff like that ' play mysterious "etc... just an info.
You can specify which of the two you are having problems with? Looks like you have that works well for onSelectionChanged(), but did not he works for onTriggered()? Is this correct or have I missed something? (Also please try to use social features shaped correctly. You can use the small "Clipboard with C" icon to insert the code with formatting preserved, to make the issue easier to read.)
Maybe you are looking for
-
FaceTime camera do not work after the installation of Sierra on MacBook Pro
After you install macOS Sierra on my MacBook Pro retina, mid-2012, the custom of FaceTime camera turn on? What should do? Mr. Elkjaer of the Denmark
-
I received a text allegedly "AppleID" saying it was a sign not allowed in the attempt on my Apple ID. This coincided with my internet connection play up. The text contains a link to reset, which I didn't click. This text is legitimate? If so, where I
-
Cannot access the Internet by Satellite M100-149
Hello My wife's cell phone is more access to the Internet: This is the info:Satellite M100-149Partnummer: PSMA2E-00R00WEDNoglefunktioner-Intel® Celeron® M processor 420-Windows original XP Home Edition-Hard drive 60 GB-768 (256 + 512) MB of RAM DDR2
-
Outlook Express not allowing the opening of e-mail
Outlook Express; Downloads of the thin server, messages to delete all right, I can't open any email or create a new one. Immediately, he tells me that he's 'met '. and error and needs to close"invites me to send the error report to Microsoft. Then it
-
I want to uninstall Picaso and install Adobe Elements. Where my pictures go when I do uninstall it? CARTX