I'm working on a project with a javascript library YUI and JSP.
I'm trying to manipulate a YUI datatable, some cells of the table are select options and input text:
What I'm trying to do is to manipulate the options of the select options input dynamically at runtime:
First, this is the declaration of the datatable:
var CustomSelectCellEditor = Y.Component.create({
NAME: 'CustomSelectCellEditor',
ATTRS: {
multiple: {
value: false,
validator: Y.Lang.isBoolean
},
strings: {
value: {
edit: 'Edit',
save: 'OK',
cancel: 'Annuler'
}
}
},
EXTENDS: Y.BaseOptionsCellEditor,
UI_ATTRS: ['multiple'],
prototype: {
ELEMENT_TEMPLATE: '<select class="celleditor-element error-field"></select>',...
var ruleTypeCreateColumns = [{editor: new CustomSelectCellEditor({editable: false,options: types}), ...
var newRulesTable = new Y.DataTable({
columns : ruleTypeCreateColumns,
width: "80%",
editable: true,
editEvent: 'click'
});
the datatable will look like, a datatable with input cells, the input editor appears in a click event:
At runtime, I tried to change the editor, for example from select options to input text, according to the input of the first column:
newRulesTable.after('*:criteriaTypeChange', function(o){
for(var i=0; i<newRulesTable.data.size();i++) {
if(newRulesTable.data.item(i).get('criteriaType') == getTypes().date) {
// TODO HERE
}
}
});
After many attempts, I couldn't reach my goal, so I need to know which object should I change?

manipulating data in runtime is a hinder when using native JavaScript, unlike famous libraries like angular , react that updates automatically your view when your data change ( two ways binding) , in native JavaScript you should implement this logic manually via listeners and pure code:
Here a simple example we want to update our select option when we click on the button
idon't really know how YUI library work but i hope this will help you a little.