Hi,
how can I format a dimension (datetime) in pivot grid?
I tried with this but it doesn't work:
//memberProvider: function (item) { return item.date; }memberProvider: function (item) { return $.formatNumber(item.date, { format: "dd/MM/yyyy" }); }
Hello Giovanni,
Thank you for posting in our forum.
What type is the value that you are trying to format?
Ignite UI has a $.ig.formatter function that you can use to format your values:
https://github.com/IgniteUI/ignite-ui/blob/master/src/js/modules/infragistics.util.jquery.js#L624
You can use it by providing the value, the value type (date, number etc.) and the format.
For example, if you are aiming to format a value of type date the code would look as follows:
$.ig.formatter(dateValue, "date", "dd/MM/yyyy")
I hope you’ll find this information useful. I’m looking forward to your reply.
Sorry but it doesn't work.
I have a datetime value and I'm trying to convert to dd/mm/yyyy format.
This is my code:
dimensions: [ { name: 'data', caption: 'data', hierarchies: [{ name: 'data', caption: 'data', levels: [ { name: 'data', caption: 'data', memberProvider: function (item) { return $.ig.formatter(item.data, "date", "dd/MM/yyyy"); } } ] }] },
It view 2018-03-30T00:00:00
I have attached a sample for your reference with a local OlapFlatDataSource where the $.ig.formatter is used to format the date object.
Please refer to the attached sample:
8863.pivot_sample.zip
and let me know if you’re aiming to achieve something similar.
Please note that the value in the data source is a Date object:
"Date": new Date("2018-03-30T00:00:00")
If in your case the data is a string, for example:
"Date": "2018-03-30T00:00:00"
Then please make sure that you create a Date object from it before passing it to the formatter function:
return $.ig.formatter(new Date(item.Date), "date", "dd/MM/yyyy");
Let me know if you have any additional questions or concerns.
Regards,
Maya Kirova
My datetime datatable is converted in json.......I used "new Date(item.Date)" and it works.
Thank you very much Maya.