Kendo-ui-core: Week Number Column

Created on 4 Nov 2016  路  10Comments  路  Source: telerik/kendo-ui-core

Ability to enable the week column in the Calendar and DatePicker widgets. Also there will be ability to calculate the week number differently if needed (for example to display a fiscal year).

Calendar DatePicker DateTimePicker Feature

Most helpful comment

Definitely an opt-in feature. We don't want to surprise anyone with a layout change.

All 10 comments

@yordanov: design welcome :)
cc @ggkrustev

I would suggest to implement the week number with a separate template, just like the month.content and month.empty. This will give the users the ability to modify the content or even to perform custom calculations there if needed.

We could go for a month.weekNumber option, which will accept a Kendo Template. The passed data will include 2 params:

function weekNumberCallback() {
 // data.weekNumber - calculated week number
 // data.currentDate - current date used for the week number calc
}

The new configuration option should be proxied to the DatePicker/DateTimePicker configuration.
Need also to add option for localization of the week number header, e.g. 'Wk'.

Thank you for the suggestions! I made some progress with the implementation of the feature, but I would like to discuss an idea:

  • Do we need a showWeek property (month.showWeek) to control whether the week column should be displayed at first place? Currently my implementation does have such property and relies on this value in the content and view methods to decide whether to render the week header/value. Alternative approach would be setting the week number template to emtpy string if showWeek is false. This will avoid the need to check the showWeek property in the content and view functions and append the weekNumber template always (after all the template is empty string if user does not want to display the week number).

Hi @boyandim,
Although, I am really keen to use just the month.weekNumber option to enable/disable the week number column, I think that we will need both:

  • showWeekNumber on root level to enable/disable the week column
  • month.weekNumber template option to control week number rendering

Here are my arguments in defence to the suggested configuration:

  • The weekNumber most probably will _not be enabled_ by default or I am mistaken? If this is true, we will need to provide an easy way to enable weekNumber without the need to specify template
  • If only template is used, disabling the week number column will require to to set month.weeNumber template to 'false' (verbose)

With the above configuration, we will be able to provide a default weekNumber template and enable/disable it on the fly.

I would be happy to hear the @tsvetomir opinion? Should we enable weekNumber by default or not? I am willing to enable it, but I am not sure how this will affect all users. The calendar is in use for the last 5 years without major changes, such rendering change is not little.

Definitely an opt-in feature. We don't want to surprise anyone with a layout change.

Thank you for your valuable feedback. I agree that it is better to have an option for disabling/enabling the week column. Therefore currently there is such option, but it is defined on month level (not at root level). I will modify it to make it a global option for the calendar.

Since this feature is already implemented I am looping @inikolova into this discussion. Could you please check the referenced issue in kendo repo for styling suggestions provided by Vassil?

Looking at the weekInYear method, it should be well explained in our documentation how we calculate the week number.
Some article like this would be helpful.
https://msdn.microsoft.com/en-us/library/system.globalization.calendarweekrule(v=vs.110).aspx

The help must also contain an example on how they can achieve something with custom function if they want, something like this:
https://blogs.msdn.microsoft.com/shawnste/2006/01/24/iso-8601-week-of-year-format-in-microsoft-net/

Indeed, as the weekInYear method will be released under kendo.date namespace, we will need to document it. Thanks for the hint.

@boyandim could you document the method in the kendo.date page? Pointing out what is the supported params and the possible return will be just fine.

Also I do believe that @boyandim will add a specific demo for the 'week number' feature and will update the current templates demo showing a custom usage. I believe this will be enough for now.

As far as I see, the material theme does not have styling for the week column:

image

Was this page helpful?
0 / 5 - 0 ratings