How to pass the generated value from the table to the editor?
How to pass the generated value from the table to the editor?
imballama
Posts: 12Questions: 5Answers: 0
I count the values in the table like this
{
'data': 'calendar',
'render': function (data,type,row) {
let count = 0;
if(isNaN(parseInt(data[`${daysInMonth[0]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[1]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[2]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[3]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[4]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[5]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[6]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[7]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[8]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[9]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[10]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[11]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[12]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[13]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[14]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[15]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[16]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[17]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[18]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[19]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[20]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[21]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[22]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[23]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[24]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[25]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[26]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[27]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[28]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[29]}`])) === false){count+=1}
if(isNaN(parseInt(data[`${daysInMonth[30]}`])) === false){count+=1}
return (
count
)
}
}
How can I pass this value to the editor field?
This question has an accepted answers - jump to answer
Answers
When you say pass to an Editor field, do you mean you want to send that value back to the server immediately? Or automatically fill in a value when the editing form loads?
Colin
I think automatically fill in a value when the editing form loads
I'm not clear on what you would do with it in Editor? If you edited the count, what would happen?
Also, it might be worth using a three line
lor
loop there rather than listing every option!Allan
It is necessary for me that these data counted in the table got to a DB. I don't quite understand how to implement this. When you open the editor, there is no such data in the corresponding fields.
Colin , I thought about it and decided that I need to immediately add them to the database. Can you help me with this?
This is how you can change the values when the form opens : http://live.datatables.net/wivatezi/72/edit
It would probably be a bad move to do it automatically - as you would be contacting the server for each row of the table on initialisation. This would be horrendously slow even for a small number of records,
Colin
I do not quite understand how to dynamically read the data in this case?
This here is doing what your code appears to be doing. It's rendering a different value into the salary field than is in the data, then that value is loaded when the record is edited.
Colin
Ok, I try this