How change editor`s row field value with function
How change editor`s row field value with function
Hi, Allan.
I'll tried create additional button in editor's form with my own function. I want change one field in the row which is currently edited. This field don't included in editor form.
I created button with label "Set state" for this task. But after how I add this button, not any buttons are displayed in datatable window.
How I can correct this situation?
editor.buttons( [
{
label: 'Save',
className: 'primary',
fn: function () {
this.submit();
}
},
{
label: 'Set state',
fn: function () {
editor
.edit( row, false );
.set( 'obr', '1' );
.submit();
}
},
{
label: 'Close',
fn: function () {
this.close();
}
}
] );
This question has accepted answers - jump to:
This discussion has been closed.
Answers
Next step I'd try: change "editor" variable to "this" - nothing changed.
And next more:
All buttons are displayed, but button "Set state" do nothing.
If I use string
in my function, value is changed, but in last line in datatable's window.
So, the next question is:
How I can set proper row index in this case? Can I use
editor.modifier()
method?it might be easier to add the field to the Editor field list and set the type to 'hidden'. This keeps it off the form, but allows Editor to access the field.
Thanks for your advice, this is exactly what I need.
Working code is:
But if I use one chain:
submit() don't working.
Why I can't use chain methods in this case?
Hi,
The
field()
method will return aField
instance rather than anEditor
instance which is why you can't chain the method like that. There is noField.prototype.submit
method.You'd need to use:
Allan
Thanks, Allan. Now all clear for me. These two lines of code use two different
this
.No - they are identical - they are the Editor instance. For example the above is the same as:
The key is what the functions return.
field()
will return aField
instance which is not anEditor
instance!Allan
Thanks for replay, Allan. I'm sorry for the misunderstanding due to my poor English;(.
I was referring to the fact that these lines are different/incompatible because of the it's returning value. That is exactly what you wrote. Thank you.