I've successfully created a UIPickerView and am using a custom ListModel tu supply the selectable items. But how can I specify which of the items should be selected when the view appears?
Thanks,
Adrian
You have to call the picker view's Select method:
pickerView.Select(1, 0, true);
This will select the second row (index 1) of the first component (index 0). The boolean is for animating the selection or not.
See the documentation.
Related
I want to control row focus process. I need to show confirm dialog on row focus change in my table.
I tried to do this with rowClassRules property, but as I understood that functionality apply classes when table rendering, after that row classes stop changing
rowClassRules = {
'custom-row-focus': (params) => {
return params.data.id === this.currentSelectedItem.id
}
}
currentSelectedItem set's when I click on the row
Found an answer in docs
https://www.ag-grid.com/javascript-grid-row-styles/#refresh-of-styles
If you refresh a row, or a cell is updated due to editing, the rowStyle, rowClass and rowClassRules are all applied again.
So, when I'm clicking to the row I should make something like that:
onClicked($event: RowClickedEvent) {
$event.node.setData({...$event.data});
}
I'm using this component:
https://github.com/Darkseal/DownPicker
let persons = ["Architect", "Designer", "Chef", "Doctor"]
self.personDownPicker = DownPicker(textField: self.personTextField, withData:persons)
And it's displaying the data correctly, but, how I can have an option selected by default?
Just looking into the source code, the DownPicker instance has a selectedIndex property. Set it to the index of the selected item.
I have list of Items with parent child relation.
At present I am displaying them in a single table. In each row, fist column starts with number of '-'s indicating the depth.
Now I want show only top level items first and with a '+' button before that.
When the user clicks on the '+' button it should turn to '-' and the children of that particular Item need to be displayed.
So, Please help me how to implement that Expand and Collapse functionality in GWT.
EDIT:
I have my Items in a tree format.
Now I am creating a DataTable and Displaying it using GoogleTableChart
The code as follows:
DataTable data = DataTable.create();
data.addColumn(ColumnType.STRING, "Item Name ");
data.addColumn(ColumnType.STRING, "Item Id");
data.addColumn(ColumnType.NUMBER, "Quantity");
data.addColumn(ColumnType.NUMBER, "Price ($)");
data.addRows(treeList.size());
int i=0;
while(i<treeList.preOrderTraversal().size())
{
int col=0;
Item d=(Item) treeList.preOrderTraversal().get(i);
int level=d.getLevel();
//setting values to DataTable goes here
i++;
}
GoogleTableChart tblChart = new GoogleTableChart();
vPanel.add(tblChart.showFlexibleTable1(data));
Here is my solution:
I create Nested VertialPanels for each Item. And put the reference in a map.
Hide/unhide the panels based on clicks.
For root Item take one panel and add all its children.
After adding one child, add all its children to another panel,hide it and add to root panel.
repeat the steps recursively.
before each row place put (+/-) label and add click handler which take item id as parameter.
when these lables are clicked, based on the status we hide/unhide the panels, taken from the map.
Any Better Solution ... ??
I have a list of items in a listView. I would like to highlight the first item of this listview so that the user knows top item is active. How can I go about doing this?
Something like the image
Try Some like tha:
create custom listview adapter like that and adapter, Custom adapter for a list of items that have multiple child items?
then set bg like that:
if (position == 0) {
// define layout here list 1st item
view.setBackground(R.drawable.bg);
} else {
// others
view.setBackground(R.drawable.bg);
}
I want to create a custom component which can have N number of ListBoxes and when one List box is selected then others should be un selected. is there way to do it.. can any one suggest me.
Thanks in advance!!
Yes you can do this.
One way to do this is and internal event bus-
1) Create an event bus for the custom widget.
2) Create a custom selected event
3) Each listbox that gets created should register a handler with this event bus for the custom selected event.
4) If a list gets selected/ focused on (whenever you want others to be deselected), it will fire the custom selected event on the event bus with its Id.
5) The other list boxes will receive this event, check if it came from them, if not, will deselect/ set selection null
Another way, rather than have the event bus control it, is to create a custom function that gets called on selection, this function will have to go through all the lists and deselect them.
Jai gave you some good ideas, but here is my code for similar functionality (not N ListBoxes, but you should be able to extend/generalize it):
#UiHandler({ "listBox1", "listBox2" })
public void onFocus(FocusEvent e) {
// If one ListBox has an item selected, and the user click's the other, unselect previous (mutually exclusive).
if (listBox1.getSelectedIndex() > -1 || listBox2.getSelectedIndex() > -1) {
if (listBox1.getSelectedIndex() > -1 && e.getRelativeElement() == listBox2.getElement()) {
listBox1.setSelectedIndex(-1);
}
else if (listBox2.getSelectedIndex() > -1 && e.getRelativeElement() == listBox1.getElement()) {
listBox2.setSelectedIndex(-1);
}
}
}
As you can see, I used the UiHandler syntax, and I performed the "is selected" check during the onFocus event. In English:
If any ListBox has an item selected (if no ListBox has an item selected, no sense in checking all of them).
If ListBox 1 has an item selected, and the (focus) event came from any other ListBox:
Yes - deselect ListBox 1 item
No - repeat step 2 for ListBox 2 ... N