autocomplete search key specify - user-interface

By default autocomplete in ace editor picks up value for search and value for substituting in the text field. Can we specify a name for search and value for substitution? Any help is appreciated.
eg for completor
var completer = {
getCompletions: function(editor, session, pos, prefix, callback) {
var f = [
{'value': '2', 'name': 'two'},
{'value': '3', 'name': 'three'},
{'value': 'four', 'name': '4'}
];
callback(null, f);
}
};
In this example, the only value is used for the search. I want to show customers a verbose text during popup but when he/she hits select value should be substituted.

Related

How to disabled a button on lightning datatable based on field value?

I want to disabled a button on a lightning datatable based on a boolean field, I came to this solution:
const columns = [
{ label: 'Client', type:'button',
typeAttributes: {
label: 'Client',
disabled: {fieldName: 'Client__c' }
} }
];
The problem is, I need to make visible when is true, but it actually doing the opposite, i search to a enabled property or trying something like this:
Client__c == true ? false : true;
but it doens't work..
I also try this solution here
this.tableData = result.data.map((value) => ({ ...value, clientDisabled: ('Client__c' == true) ? false : true }));
And the column:
const columns = [
{ label: 'Client', type:'button',
typeAttributes: {
label: 'Client',
disabled: {fieldName: 'clientDisabled' }
} }
];
Also, not work, all buttons became disabled.
Also, I would like to put a - when is disabled (and the field = false), like this:
'Client__c' == true is always false; you're comparing two literal values that will never be equal. You'll want to use the data from the record instead:
this.tableData = result.data.map((record) => ({ ...record, clientDisabled: !record.Client__c }));

How to pass value from field to a wizard in Odoo 13?

Im using two models for two form views.
I have this field below with model 1
name = fields.Many2one('hr.employee', string="USERNAME", required=True)
And I want to pass its value to the wizard when I click a button. Here's the code:
def create_field(self):
return {
'name': self.name,
'view_mode': 'form',
'res_model': 'dieu.chinh',
'view_id': False,
'res_id': wiz.id,
'res_id' : self.id,
'context': {'current_id': self.id},
'target': 'current',
'type': 'ir.actions.act_window',
}
The button in XML file:
button type="object" string="SUBMIT" name= "create_field" class="oe_highlight"/>
After clicking the button, it can open the expected form view with model 2, but still not show the value which was selected in the previous form.
So... How to pass value from field to a wizard in Odoo 13?
Please help!
Thank you!
Try this:
def create_field(self):
form_view = self.env.ref("your_wizard_form_view_external_id")
return{
'name': 'Wizard Name',
'views': [
(form_view.id, 'form'),
],
'res_model': 'dieu.chinh',
'target': 'new',
'type': 'ir.actions.act_window',
'context': {
'default_wizard_field_name': self.name.id, # for passing Many2One field context value in Wizard form view
},
}
'default_wizard_field_name': self.name.name # for passing Char field context value in Wizard form view

backbone- go through collection, and render in correct order?

How to be sure that all of the view-s will be displayed in correct order. because of use of Ajax, first one finished will be displayed first, i want to always be displayed in right order...
_.each(view.collection.models, function (category) {
var productBlockListView = new ProductBlockListView({model: category});
productBlockListView.setElement(view.el).render();
}, this);
Use a comparator option to get a sorted collection.
var items = new Backbone.Collection([{
firstName: 'Steve',
lastName: 'Jobs'
}, {
firstName: 'Bill',
lastName: 'Gates'
}], {comparator: 'firstName'});
items.each(function(item) {
console.log('%s %s', item.get('firstName'), item.get('lastName'));
});
Documentation
Demo

devbridge ajax autocomplete doesn't update suggestion list

I am using devbridge ajax autocompletion script http://www.devbridge.com/projects/autocomplete/jquery/. When I type something in the textfeild, the suggestion list does show up and the matched portion of the words are correctly highlighted. However, the problem is the list remains static. In other words, the suggestion list basically functions like a dropdown list. All the items (matched or not) remain on the list, and in the same order, no matter what you type in the text field.
Anybody can tell me what the problem is? Thanks!
To answer your question, Anyone need code what you are using for this.
I will reply after understanding your code.
Sample Code :
$ (document). ready (function ()
{
$('#searchresult').autocomplete(
{
serviceUrl: 'search.php',
minChars: 1,
delimiter: /(,|;)\s*/, // regex or character
maxHeight: 400,
zIndex: 9999,
deferRequestBy: 0, //miliseconds
noCache: false, //default is false, set to true to disable caching
// callback function:
onSelect: function(value, data){ alert('You selected: ' + value + ', ' + data); },
// local autosugest options:
lookup: ['January', 'February', 'March', 'April', 'May'] //local lookup values
});
});

Select a row in jqGrid based on cell value

colModel: [
{ name: 'Id', index: 'Id', hidden: true, search: false },
{ name: 'Name', index: 'Name', hidden: true, search: false },
]
Just as the setSelection method allows selection of a row in jqGrid based on the row number, is it possible to similarly select a row based on one of the cell values.
For e.g. in the colModel above, is it possible to select a row having a certain 'Id' or 'Name' value...assuming that these values are unique for each row.
In the loadComplete: portion of your jqGrid you could iterate over each row and test for the value you are looking for. If the value is found, select the row.
Ex
loadComplete: function () {
var rowIds = $(this).jqGrid('getDataIDs');
for (i = 1; i <= rowIds.length; i++) {
rowData = $(this).jqGrid('getRowData', i);
if (rowData['Id'] == idSearchValue ) {
$(this).jqGrid('setSelection',i);
} //if
} //for
...
There would also be the rowattr: but I can't seem to find where you can get the rowID of the current row. Oleg might see this and respond as well as it was his addition to jqGrid but I didn't have any luck with my testing or read though of where you would get the current rowId to pass to the setSelection method.
If you have an array of objects containing cells values, you will need another approach.
Eg. with your colModel, you would like to retrieve rows with these values:
let toSearch = [
{ Name: 'Arthur', Id: 150},
{ Name: 'Julien', Id: 90},
]
Then what you can do is to retrieve the whole data from the jqGrid table and seek after values dynamically:
let data = $grid.jqGrid('getGridParam', 'data');
let toSelect = data.filter((row,i) => {
return toSearch.some(toSelectRow => {
for(let prop in prevRow) {
if(prevRow[prop] != row[prop])
return false;
}
return true;
})
});
toSelect.forEach((row) => $grid.jqGrid('setSelection',row.id, false)); // Prevent firing onSelectRow event
Here we pass false to prevent from firing onSelectRow event, if you need it just remove false

Resources