Don't display "null" in Grid

22 posts, 0 answers
  1. Tak
    Tak avatar
    1 posts
    Member since:
    Sep 2011

    Posted 29 Mar 2012 Link to this post

    Hallo Kendo Team.
    I have got incomming data, which contains null values. For example FirstName is empty (null).
    Kendo grid display "null", but it is funny FirstName. I want to display "" (nothing) instead of "null".
    Is there any way how to do it? ( without changing incoming data)
    Thnx. uf.

  2. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2255 posts
    Member since:
    Sep 2012

    Posted 30 Mar 2012 Link to this post

    Hi Tak,

    The functionality that you described could be achieved using a template. Since the template allows use of JavaScript code inside its definition, you could perform a simple check if the corresponding value is null and return an empty string. In this jsFiddle example you could see this approach in action.

    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!

  3. Jakob Zetterström
    Jakob Zetterström avatar
    4 posts
    Member since:
    Apr 2010

    Posted 26 Apr 2012 Link to this post

    And for (batch) editing? Which kind of editor template do you propose?

  4. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2255 posts
    Member since:
    Sep 2012

    Posted 01 May 2012 Link to this post

    Hello Jakob,

    The default editor for date fields is a date picker widget.
    If you want to define your own editor I suggest to follow the example from our custom editor demo and implement a editor function that best fits in your requirements. In case you are asking how to prevent the displaying of null values in batch editing mode, you could use the approach described in my previous post.

    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!

  5. Jakob Zetterström
    Jakob Zetterström avatar
    4 posts
    Member since:
    Apr 2010

    Posted 02 May 2012 Link to this post

    Hi Alexander,

    Umm... no, I can't use the approach described in your previous post. I use a custom DatePicker editor, and even though the model value is null, I can't keep the editor from displaying a "null" string value in its textbox when it is activated. Could you please update the fiddle to show how this is done with the grid simply set to editable = true?

    Thanks,
    Jakob

  6. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2255 posts
    Member since:
    Sep 2012

    Posted 04 May 2012 Link to this post

    Hi Jakob,

    I tested this scenario and everything seems to work as expected on my side.
    Please check my sample page and let me know if I missed something.

    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!

  7. Felipe Casanova
    Felipe Casanova avatar
    56 posts
    Member since:
    Feb 2010

    Posted 01 Jul 2012 Link to this post

    Alexander, Are you suggesting that anywhere there is likely to be a null value that we have to use a template? This seems like more of a work-around than a way to solve the problem. Are there any plans to change this behaviour please? I can't think when displaying "null" to users is a good idea. Thanks Matt

  8. Jesper
    Jesper avatar
    25 posts
    Member since:
    Jun 2012

    Posted 03 Jul 2012 Link to this post

    I absolutely agree with Matt. We should not have to resort to templates to prevent the user from seeing a null value.

  9. Alexander Valchev
    Admin
    Alexander Valchev avatar
    2255 posts
    Member since:
    Sep 2012

    Posted 04 Jul 2012 Link to this post

    Hi guys,

    I am afraid that at present we do not have plans to change the default behaviour, nevertheless be sure that I will forward your feedback to the team. What I can suggest at the moment, is to vote for this idea at Kendo user voice forum - if it turns out to be popular our team will look into it further.

    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!

  10. Tim
    Tim avatar
    4 posts
    Member since:
    May 2012

    Posted 06 Aug 2012 Link to this post

    I totally agree with Matt and Jesper. This is not acceptable - especially for string values. Null strings should be displayed as '', not 'null'.

    Additionally, there should be a property on the grid for a 'no-data' template.

  11. Muhanad
    Muhanad avatar
    1 posts
    Member since:
    Aug 2012

    Posted 07 Aug 2012 Link to this post

    Using template fixes the null issue but seems to create another issue in the cell where a null value exist. The column line on the left disappears on every cell that has a null value. This only happens ie....
    Agree with everyone on this thread...I think this is a defect that needs some fixing :)

  12. Felipe Casanova
    Felipe Casanova avatar
    56 posts
    Member since:
    Feb 2010

    Posted 07 Aug 2012 Link to this post

    Looks like enough votes were received. Following Alexanders vote link shows that this behaviour has been changed and it will be included in the next official release. Matt

  13. Rodney
    Rodney avatar
    23 posts
    Member since:
    Jan 2011

    Posted 27 Aug 2012 Link to this post

    So how would you do this using a row template? 

  14. Dimo
    Admin
    Dimo avatar
    7497 posts
    Member since:
    Sep 2012

    Posted 28 Aug 2012 Link to this post

    Hi Rodney,

    You should use a template with an expression (IF statement) inside.

    http://demos.kendoui.com/web/templates/expressions.html

    ("Using JS code in the template definition")

    http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/faq

    ("How do I have conditional logic in a column client template?")

    Regards,
    Dimo
    the Telerik team

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  15. Kjell Ivar
    Kjell Ivar avatar
    1 posts
    Member since:
    Jul 2012

    Posted 23 Oct 2012 Link to this post

    Hello.
    I wonder what is the status for this issue.
    Is this going to be included in the next release of KendoUI? And eventually when will that be? I totally agree with the other people here that this is a important issue to be fixed. It is not a good solution to include templates for all fields that need to display '' instead of null.

  16. Dimo
    Admin
    Dimo avatar
    7497 posts
    Member since:
    Sep 2012

    Posted 23 Oct 2012 Link to this post

    Hello Kjell Ivar,

    The fix is already available in the Q2 2012 SP1 release (2012.2.913).

    Greetings,
    Dimo
    the Telerik team

    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  17. Jon
    Jon avatar
    4 posts
    Member since:
    Jan 2012

    Posted 02 Jan 2013 Link to this post

    ....which still does not work if the value is set via ClientTemplate.

  18. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8255 posts
    Member since:
    Sep 2012

    Posted 02 Jan 2013 Link to this post

    Hello,

    The grid give full control to the client template. Checks for null should be performed in the template.

    Kind regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  19. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 06 Mar 2013 Link to this post

    I too would be in favor of making '' the default behavior.  Still doesn't seem to be the default when using the web 2013 version.

  20. Atanas Korchev
    Admin
    Atanas Korchev avatar
    8255 posts
    Member since:
    Sep 2012

    Posted 07 Mar 2013 Link to this post

    Hi Travis,

     Here is a live demo showing that null values are not displayed by default (using the latest official version): http://jsbin.com/obikoq/1/edit

     And here is the same example using the Q1 2013 beta version: http://jsbin.com/okopaz/1/edit

    Kind regards,
    Atanas Korchev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!

  21. Travis
    Travis avatar
    223 posts
    Member since:
    Jan 2003

    Posted 07 Mar 2013 Link to this post

    My mistake.  I'm using an older version for the Kendo UI controls.  I confused this with another project I was working on.  Sorry!

  22. Brady
    Brady avatar
    34 posts
    Member since:
    Mar 2009

    Posted 09 Jun 2013 Link to this post

    That second example (Q1 2013 beta version) is utterly useless. It doesn't show the column or template definition.

Back to Top