mRender, mData pass Field name

mRender, mData pass Field name

tstartstar Posts: 36Questions: 0Answers: 0
edited October 2012 in DataTables 1.9
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?

Replies

  • tstartstar Posts: 36Questions: 0Answers: 0
    I'm sorry, a small error
    [code]Int: function (val, type, data, field) {
    ....
    return data[field + "_filterВ"];
    }[/code]
  • allanallan Posts: 63,204Questions: 1Answers: 10,415 Site admin
    Good idea - I like it. I'm planning on increasing the importance of column names in DataTables 1.10, so this might be a nice addition there. That's for suggesting this - I've added it to my todo list to investigate the impact of adding this to the API.

    > 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
  • tstartstar Posts: 36Questions: 0Answers: 0
    Thank you very much for the wonderful news!
  • tstartstar Posts: 36Questions: 0Answers: 0
    It may be worth add custom renderers as an extension to the tables similar to the sorting plugins based on the type of the field?
  • allanallan Posts: 63,204Questions: 1Answers: 10,415 Site admin
    Possibly - although probably not as part of DataTables core at the moment. The grand plan it to make it modular ( http://datatables.net/development/roadmap ) so a bunch of default rendered in the current monolithic core isn't really where I'd want to go, but when 1.11 comes around with the more modular architecture, then renders could be optional extras as part of the package builder (with a libraries of plug-ins much like I've got for sorting, type detection etc in Github at the moment).

    Allan
This discussion has been closed.