Problem with custom unformat for simple text columns
unle70 opened this issue · comments
Hi Tony,
I see a problem (limitation) with custom unformat when using simple text columns and cellEdit. Here is my analysis:
My custom unformat returns null
when the grid cell content is an empty string or
. This works well for me since it is symmetric. If the server provides null
data, the grid will hold
and so I would like the reverse operation (unformat) to return the original value.
When using editCell, there's a call to "$.unformat" going on:
tmp = $.unformat.call($t,cc,{rowId: $t.rows[iRow].id, colModel:cm},iCol);
This "$.unformat" function can handle cases where the custom unformat returns undefined
, but does not do any special handling to null
values being returned, and just returns the null
as is:
return ret !== undefined ? ret : cnt===true ? $(cellval).text() : $.jgrid.htmlDecode($(cellval).html());
Then, the editCell code cannot handle this null
value properly as it tries to do .length
and .charCodeAt
on it:
if(tmp === " " || tmp === " " || (tmp.length===1 && tmp.charCodeAt(0)===160) ) {tmp='';}
So I guess should either provide some checking and handling for returned null
values, or maybe write in the documentation that returning null
from unformat is not allowed.
Thanks Udi,
I think I have fixed the problem. Please let me know if it is ok.
Hi Tony,
Yes, It's OK now.