This is a migrated thread and some comments may be shown as answers.

Need to change column definition based on certain conditions

7 Answers 292 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Khushali
Top achievements
Rank 1
Khushali asked on 28 Mar 2012, 11:42 AM
Hi,

I have a kendo grid. And there is a dropdown. In the grid there is a column having a date field. Now, this date column's data format should be changed according to the value chosen from the dropdown. Suppose, i choose daily or hourly in the dropdown, then i have to display date with time(in the format hh:mm:ss). Suppose i choose weekly, then i have to display date with time(in the format hh).And if i choose monthly or yearly, then only date should be displayed. I am not able to get, how can i change the column definition dynamically. And also, from the server i am getting a date object only as i also have to filter and sort on that column. I am using a template for this column to specify the format. But, depending on various conditions, how can i change the format? Please suggest.

Thanks,
Khushali

7 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 28 Mar 2012, 04:12 PM
Hi Khushali,

Kendo templates allow use of JavaScript code inside their definition, so you could implement the described logic using conditions. I suggest to catch the change event of the dropDownList and set a flag according to which the date format will change. In this example you can see the aforementioned approach in action.

I hope this information helps.

All the best,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Khushali
Top achievements
Rank 1
answered on 29 Mar 2012, 05:37 AM
Hi Alexander,

That seems to be helpful. But can you tell me, if i have time also with date in that column, will filter work on it? It is working right now only for the options like "is before", "is after" but not for "equal to". Is there any way that we can ignore the time while filtering on date?

Regards,
Khushali
0
Alexander Valchev
Telerik team
answered on 29 Mar 2012, 09:09 AM
Hello Khushali,

Currently this functionality is not supported out of the box. It could be implemented by preventing default filter behaviour and creating a custom filter function. For convenience I am attaching an demo page that shows this approach in action. Please have in mind that this is a sample implementation - you will have to adjust the field selectors according to the configuration of your grid.

Kind regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Khushali
Top achievements
Rank 1
answered on 29 Mar 2012, 10:26 AM
Thanx Alexander.. I tried opening that html, its not working in my browser. Dont know what is the issue.

Regards,
Khushali
0
Alexander Valchev
Telerik team
answered on 29 Mar 2012, 11:09 AM
Hello Khushali,

I tested the page once again in all major browsers and it seems to work on my side. The problem might be caused by IE security restrictions. Could you please tell me what browser you are using or if there are any errors on the page?

Thank you in advance.

Greetings,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Khushali
Top achievements
Rank 1
answered on 29 Mar 2012, 11:13 AM
Hi,

I am using Firefox 3.5.2. It gives this error:

Error: uncaught exception: [Exception... "Operation is not supported"  code: "9" nsresult: "0x80530009 (NS_ERROR_DOM_NOT_SUPPORTED_ERR)"  location: "http://code.jquery.com/jquery-1.7.1.min.js Line: 2"]

Regards,
Khushali
0
Alexander Valchev
Telerik team
answered on 29 Mar 2012, 04:49 PM
Hi Khushali,

The problem seems to be caused by the version of your browser - Firefox v.3.5.2 is not officially supported. Please try to open the sample with Firefox ESR or newer and let me know if you still experience the same problem.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Khushali
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Khushali
Top achievements
Rank 1
Share this question
or