Select an Ext.Picker field by default - sencha-touch

I've created a Picker in a form in my sencha app. The field is empty by default. How do I set it to be selected on the first item in the data array?

It automatically selects the first item in data array (node 0) ... if the first item is empty and you want it to be on the 2nd item you can (assuming a the component variable is called picker) use picker.items.items[0].setSelectedNode(1)

Related

Computed Property not rerendering

When a component data value ( which is array with objects ) changes the computed property is not affected.
In the example below, I have a table that is filled with some data ( it is tasks in different statuses with titles ). If you click on a task and you click the button 'CHANGE TASK INFO' it will change the current task selected to
{
Status = QA Review
Title = TEST
}
However if you comment the 99,100 lines and uncomment the 96 line the things are not the same anymore if you try to click the button with a different task selected the task is updated in the 'tasks' variable of the component but never rerendered by the computed prop.
Any ideas ?
SB
https://codesandbox.io/s/vue-table-test-enviroment-bx1sd?file=/src/components/HelloWorld.vue
Vue is not able to detect changes if you replace an array item by index (see Reactivity in Depth).
The solution is simple:
this.$set(this.tasks, indexOfUpdatedTask, test);

select nothing in many2one widget

I have a many2one field for which the selection of nothing (e.g. none, false, null) is a normal and valid state.
However the many2one widget in Odoo per default allows no empty selection. After a the record has been set, the user cannot unset the field with the normal widget.
Is there maybe some flag or Odoo feature that I can use to enable null selection?
As described in the comments, an empty value is selected when all text in the many2one widget is removed and one clicks outside.
So you can select from the drop down an item. When you remove part of the items name, it is still selected. When you remove all text in the field, the selection changes to empty. I was not aware of this because I am used to having an empty row at the top or bottom in the drop down that represents the null selection.
If you want to assign empty value for a Many2one field through code try this:
self._your_many2one_field = 0
And if you want to select blank in a Selection field try this:
self._your_selection_feild = False

Getting value of previous selected item (dropDown)

When a user changes the selected item on a dropdown I need to get the PREVIOUS item selected,
EX:
dropdown items:
1) Questions
2) Jobs
3) Tags
4) Badges
User has #2 Selected and then changes to #4 -- How can I get the value of #2 when they change the selection?
Declare an instance variable in your form (WinForms) or window (WPF).
When a user selects an item:
Do what you want to do.
Save the current item index in the instance variable.
In step 1, you can now access the instance variable to get the previously selected item.
Declare a global variable that will contain the previous value.
When the user changes the selection in the combobox, set the variable to the currently selected value. Allow the selection to be changed. You now will have the previous value.
If you need to have the history of changes, then the global variable would be a collection. Then on changed event, add the current selection to the collection.
If your control is bound to data, there is no need to "Squirrel" the old value away, your data provider usually does this for you.
For example, if you are bound to a DataRow, this code will get the previous value.
? = [Your DataRow].item("[Your column name]",OrigialVersion)
This varies based on your data but ultimately, you could always re-query the database to get the original value as well.
Regardless of what you are bound too, if you ask the datasource for it's value during the Validating event of the control, it will have not changed yet so it will give you the old value, which you can then compare against the current selection.
Lastly, if you are not bound to data, I typically store the old value in the TAG property on the GotFocus event of the control. Then you can compare against that.
Hope this provides some other options that might help you, depending on your case.

Getting selected item from combobox itemrenderer and storing in object

I have a combo box itemrenderer in datagrid column. I want to get the user selected item from the dropdown of the row(s) (User may select values from combo box from multiple rows of datagrid) and corresponding values of all other columns of the rows and store it in an object . Then pass this object to database to update only those rows that user has changed.
I am able to get the selected item from combo box using "event.currentTarget.selectedItem" and corresponding values of all other columns of the rows using "valueSelect.ID", etc where valueSelect is object which contains data for datagrid. But am stuck with, how to store the selected item value of the combobox and corresponding values of all other columns of the rows into an Object?
I am seeking sample code to store selected item from combobox and its corresponding values of all other columns into an object which I can send to db.
If you're using Flex, you can bind the selectedItem property / object of the DataGrid to an Object (of the "type" used to render the ItemRenderer).
Or you can do it manually, store a reference to that object by declaring an Object (or some specific type) and then updating that value whenever a selection occurs.
So for example :
[Bindable]public var selectedItem:Object;
...
public function onComboBoxChanged(evt:ListEvent):void
{
selectedItem = dataGrid.selectedItem;
...
// comboBox specific logic here
...
}
That or, if you need something complex, possibly check out this post for a custom item renderer :
Flex DataGrid with ComboBox itemRenderer
Hope that helps!

dijit.form.Combobox show label Instead of value

I've a dijit.form.Combobox field which uses a ItemFileReadStore to pull Its data.
Teh ItemFileReadStore has two attribute per Item value which will be used for form submission , generally Unique Integers and label which is Human Understandable String.
In ComboBox HTML I've done searchAttr="value" labelAttr="label"
When the ComboBox Shows the list it uses teh label Attribute.
But When the User selects one of the Item it shows the value of that Item.
What I want is , The value Attribute will Still be used for Form Submission. But the User will always see the label in the combobox Control.
alt text http://img822.imageshack.us/img822/6660/dijitcombo.jpg
e.g. I Want to Show The Label for value 3 (Admin) instead of 3
Use FilteringSelect instead of Combobox.
Note: ComboBox only has a single value that matches what is displayed while FilteringSelect incorporates a hidden value that corresponds to the displayed value.
I have tried the following.
var cmbObject = Registry.byId('combo dojo id'); var id =
cmbObject.item.<Code Property>;
You should check if item is null.