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
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified
Accepted Solution

Item add dual into SystemListDialog

Hello All,

 

           Today i try fro SystemListDialog but fetch some issue.

  

           First tiem dialog open ok but after that if open second time dialog at that time item add dual.So may i know how to clear this item???

 

          Code :-

 

            

import bb.cascades 1.0
import bb.system 1.0

Page {
    attachedObjects: [
        SystemListDialog {
            property bool created: false
            id: listDialog
            title: "Gender"
            selectionMode: ListSelectionMode.Single
            confirmButton.label: "Ok"
            cancelButton.label: "Cancel"
            onFinished: {
                if (listDialog.result == SystemUiResult.ConfirmButtonSelection) {
                    console.log("Selected Value" + listDialog.result);
                } else if (listDialog.result == SystemUiResult.CancelButtonSelection) {
                    listDialog.cancel();
                    listDialog.clearButtons();
                }
            }
        }
    ]
    Container {
        //Todo: fill me with QML
        Button {
            text: "QML Dialog"
            onClicked: {
                if (! listDialog.created) {
                    listDialog.appendItem("Male")
                    listDialog.appendItem("Female")
                }
                listDialog.show()
            }
        }
    }
}

 

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Item add dual into SystemListDialog

Hi,
You did not set "listDialog.created = true" inside of if ().

Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 1,746
Registered: ‎04-08-2010
My Device: Passport Silver, PRIV
My Carrier: Telekom.de, O2, Vodafone

Re: Item add dual into SystemListDialog

what about setting your property to true ? ;-)

now it's always !created

-------------------------------------------------------------------------------
ekke (independent software architect, rosenheim, germany)

BlackBerry Elite Developer
BlackBerry Platinum Enterprise Partner
International Development native Mobile Business Apps
BlackBerry 10 | Qt Mobile (Android, iOS)
Workshops / Trainings / Bootcamps

blog: http://ekkes-corner.org
mobile-development: http://appbus.org Twitter: @ekkescorner
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: Item add dual into SystemListDialog

Smiley Happy

 

Thanks all.

Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: Item add dual into SystemListDialog

How get the selected item value???

Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: Item add dual into SystemListDialog

Any one know how get the selected value into SystemListDialog???

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Item add dual into SystemListDialog

SystemListDialog has selectedIndices property, which is a list of indexPaths. I think it can be treated as a JavaScript array.

http://developer.blackberry.com/native/reference/cascades/bb__system__systemlistdialog.html#property...

If selection mode is set to Single, it should contain only one entry. Something like this should work:

if (selectedIndices.length > 0) {
  var indexPath = selectedIndices[0]
console.log('indexPath is ' + indexPath)
} else {
console.log('no selection');
}

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: Item add dual into SystemListDialog

Hi Zmey,

 

    Thanks for reply but actully i need value so may i know how get value??

 

    E.x. There are 2 radio button 1. Male and 2. Female so how get this text??

Developer
Posts: 1,524
Registered: ‎12-18-2012
My Device: Z30, Z10 LE, DevAlpha C, PlayBook

Re: Item add dual into SystemListDialog

The text cannot be retrieved according to docs:

http://developer.blackberry.com/native/reference/cascades/bb__system__systemlistdialog.html#function...

But, as the order is known, indexPath can be mapped back to text easily:

 

Page {
  property string maleString: "Male"
  property string femaleString: "Female"

  function selectionToString(i) {
    if (i == 0)
      return maleString
    else
      return femaleString
  }

...

listDialog.appendItem(maleString)
listDialog.appendItem(femaleString)

...

if (selectedIndices.length > 0) {
  var index = selectedIndices[0]
  var text = selectionToString(index)
  console.log(text)
}

 


Andrey Fidrya, @zmeyc on twitter
Developer
Posts: 692
Registered: ‎08-09-2010
My Device: Not Specified

Re: Item add dual into SystemListDialog

Hi Zmey,

 

       If we don't know about order or value then how get the selected value??

 

       E.x If i append all value thrw for loop and i don't know id then how i get the value??