use data from one column as default for another
use data from one column as default for another
MadMax76
Posts: 149Questions: 33Answers: 1
Hi,
in
http://freigabe.kontura.at/test/posit.html
I am showing this data:
{ data: "pos_netto1" , editField: "Nettoposition", render: $.fn.dataTable.render.number( '.', ',', 2, '' ), className: 'dt-body-right'},
and in the editor I define this:
{ label: "Netto", name: "Nettoposition", default: "pos_netto1", render: $.fn.dataTable.render.number( '.', ',', 2, '' )},
but the "default" does not work, instead of the value of "pos_netto1" the word itself is copied as default.
How can I change this?
Thanks
Max
Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You may want to use
dependent()
for this. See Colin's example in this thread.Kevin
HI Kevin,
I studied those examples and will use "dependend" in future...
But i think for this case this is not what I need, my problem-descirption was misleading - sorry!
Trying to make this clear:
ALready on the sql-server I have a "real" value and a "proposed" value. If there is a real value, those will be the same. If the real value is NULL, then the proposed value is something different. If this is not edited, in future the proposed value will be used.
To make it more complicated, the real value comes from the table directly, the proposed value from a view with a lot of calculations (which I use as readTable).
The datatable hat as field definition:
For the end-user it will be strange to see a value in the table and when opening the editor, not seeing a value in the same field. Therefore I tried this in the editor-definition:
but this kills the whole datatable as 'proposed' is not a editor-field...
So whenever real is null, I want the proposed as default.
I hope I have been able to make this understandable,
thanks
Max
Hi Max,
Yes,
default: editor_pos.field('proposed').value
wouldn't work, because the value (editor_pos....
) is evaluated when that code runs. Whereas you actually want the value to be evaluated when you trigger the create action - that can be done with a function:However, that isn't actually a good idea to use that approach since it is order dependent. It needs the
proposed
value to be set first. Instead, I would suggest you use theinitCreate
event:Allan
Hi Allan,
I changed this slightly to
however this
does cause an error not permitting any changes; I also tried with a different field but pos_netto1 (as this is not part of the editor), but still does not work. If I leave thsi line away and put any number instead of 'val' in works.
Thanks!
Max
Ah - looking at the page I see the issue. You don't actually have a
pos_netto1
field - so we need to get that value from the selected row in the DataTable:Allan
almost there!! Catching the value now works, but: Only when i select the row. Inline editing is "blocked" until I select one row, then I can do an inline-edit in any row - but the values propsed always come from the selected row, which ist an interesting feature but not what it should do...
I tried table.row('.active')., but that does not work at all.
Thanks
Max
Ah yes, I hadn't considered inline editing. Try this - it's a little simpler anyway:
Allan
THANKS!!!!!!