Hi, I want to know how to call the template function for certain column value. I mean the function that the grid applies to a dataSource value to get the value that shows on the grid. I´m not defining any template function for that column, what i need to know is what function the grid applies to every value on a column that doesn´t have a custom template function.
Example:
-In the dataSource i have a date value: Date {Mon Aug 11 2014 00:00:00 GMT+0200}
-In the grid, after the template function i´m looking for is applied to this value, you can see: 11/08/2014.
I´ve looked for it, but couldn´t find it.
Thanks a lot.
Example:
-In the dataSource i have a date value: Date {Mon Aug 11 2014 00:00:00 GMT+0200}
-In the grid, after the template function i´m looking for is applied to this value, you can see: 11/08/2014.
I´ve looked for it, but couldn´t find it.
Thanks a lot.
7 Answers, 1 is accepted
0
Hello Juan,
Perhaps you are looking for the kendo.toString method, which is used to format dates and numbers.
Regards,
Alexander Popov
Telerik
Perhaps you are looking for the kendo.toString method, which is used to format dates and numbers.
Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Fernando
Top achievements
Rank 1
answered on 05 Sep 2014, 10:09 AM
Hello Alexander,
First of all thanks for the answer. I think that function is not exactly what i'm looking for.
I want to know what method the grid calls internally to show the data, based on the locale of kendo, a method I can call for every column of every grid withouteven think of what kind of data is stored in every column.
I suppose I don't have to define a template for every type of data in the grid.
My goal is to show in an alert, for example, the data of the datasource with the same style as is shown in the grid.
![]()
Thanks.
First of all thanks for the answer. I think that function is not exactly what i'm looking for.
I want to know what method the grid calls internally to show the data, based on the locale of kendo, a method I can call for every column of every grid withouteven think of what kind of data is stored in every column.
I suppose I don't have to define a template for every type of data in the grid.
My goal is to show in an alert, for example, the data of the datasource with the same style as is shown in the grid.
Thanks.
0
Fernando
Top achievements
Rank 1
answered on 05 Sep 2014, 10:11 AM
0
Fernando
Top achievements
Rank 1
answered on 05 Sep 2014, 10:15 AM
Hi again,
now i sent the wrong file... I resend the correct one.
Sorry for my blunder.
now i sent the wrong file... I resend the correct one.
Sorry for my blunder.
0
Hello again Juan,
Basically the Grid calls the toString internally in order to format the dates according to the currently used culture. You can do the same in order to show formatted date in the alert. For example:
I would also recommend checking the date formatting article for additional details.
Regards,
Alexander Popov
Telerik
Basically the Grid calls the toString internally in order to format the dates according to the currently used culture. You can do the same in order to show formatted date in the alert. For example:
alert(kendo.toString(dataSource.data()[0].fechaGeneracion, "d"))I would also recommend checking the date formatting article for additional details.
Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Fernando
Top achievements
Rank 1
answered on 09 Sep 2014, 09:52 AM
Hello again Alexander,
thanks for the answer, it's been very helpful. I have another question, I hope it is the last one.
If i want to do the same thing with a number value, for example, I'll have more than one type to format. I have to distinguish manually what format i should use? or there is some function or field that i can use?.
I mean by manually something like this :
(pseudo code)
if (data.type == date) {
alert(kendo.toString(dataSource.data()[0].fechaGeneracion, "d"))
}
else if (data.type == number) {
alert(kendo.toString(dataSource.data()[0].numero, "n"))
}
Or with an existing function (or a field or something):
(pseudo code)
alert(kendo.toString(dataSource.data()[0].numero, dataSource.data()[0].numero.dataType))
thanks for the answer, it's been very helpful. I have another question, I hope it is the last one.
If i want to do the same thing with a number value, for example, I'll have more than one type to format. I have to distinguish manually what format i should use? or there is some function or field that i can use?.
I mean by manually something like this :
(pseudo code)
if (data.type == date) {
alert(kendo.toString(dataSource.data()[0].fechaGeneracion, "d"))
}
else if (data.type == number) {
alert(kendo.toString(dataSource.data()[0].numero, "n"))
}
Or with an existing function (or a field or something):
(pseudo code)
alert(kendo.toString(dataSource.data()[0].numero, dataSource.data()[0].numero.dataType))
0
Hi Juan,
Since there are different formatting options for numbers and dates, the best approach would be to check the data type first. This could be done either by using some third party library (or jQuery plugin) or by checking the type specified in the DataSource's schema.model configuration.
Regards,
Alexander Popov
Telerik
Since there are different formatting options for numbers and dates, the best approach would be to check the data type first. This could be done either by using some third party library (or jQuery plugin) or by checking the type specified in the DataSource's schema.model configuration.
Regards,
Alexander Popov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!