mRender, mData pass Field name
mRender, mData pass Field name
tstar
Posts: 36Questions: 0Answers: 0
Hello!
I want to create a collection of standard renders for mRender (or mData) and I really liked the idea of caching, but I can not do that, because an external function does not get the name of the field being processed. It would be great to pass the column name in the fourth parameter in mRender function. I will show this. Now I do this like:
[code]
Int: function (val, type, data) {
if (type === 'display') {
return Globalize.format(val, "n0");
}
return val;
}
[/code]
and in DataTable:
[code]{ "aTargets": [1], "mData": "Payment", "mRender": Int }[/code]
I want to do something with caching like these examples on this page: http://datatables.net/blog/Orthogonal_data but I do not want to repeat the same code for each table field. My suggestion - add a fourth parameter to the function for the field name, which may look like function (val, type, data, fied) for mRender, then I can use it like [code]return data[phone + "_filterВ"];[/code] in my standart render function. But I do not see how this can be implemented for mData, because in my case, I set the name of the field in mData, that deprives me of the opportunity to use function for mData. What do you think about my idea? This can be realized?
Thank you in advance.
PS: When a version 1.9.4 will be available on NuGet?
I want to create a collection of standard renders for mRender (or mData) and I really liked the idea of caching, but I can not do that, because an external function does not get the name of the field being processed. It would be great to pass the column name in the fourth parameter in mRender function. I will show this. Now I do this like:
[code]
Int: function (val, type, data) {
if (type === 'display') {
return Globalize.format(val, "n0");
}
return val;
}
[/code]
and in DataTable:
[code]{ "aTargets": [1], "mData": "Payment", "mRender": Int }[/code]
I want to do something with caching like these examples on this page: http://datatables.net/blog/Orthogonal_data but I do not want to repeat the same code for each table field. My suggestion - add a fourth parameter to the function for the field name, which may look like function (val, type, data, fied) for mRender, then I can use it like [code]return data[phone + "_filterВ"];[/code] in my standart render function. But I do not see how this can be implemented for mData, because in my case, I set the name of the field in mData, that deprives me of the opportunity to use function for mData. What do you think about my idea? This can be realized?
Thank you in advance.
PS: When a version 1.9.4 will be available on NuGet?
This discussion has been closed.
Replies
[code]Int: function (val, type, data, field) {
....
return data[field + "_filterВ"];
}[/code]
> PS: When a version 1.9.4 will be available on NuGet?
No idea I'm afraid - you'd need to ask the NuGut package maintainer ( http://nuget.org/profiles/betoxiq ). It isn't actually part of the DataTables core project.
Allan
Allan