Don't display "null" in Grid

1 Answer 5715 Views
Grid
Tak
Top achievements
Rank 1
Tak asked on 29 Mar 2012, 07:38 PM
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.

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 30 Mar 2012, 12:40 PM
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!
Jakob Zetterström
Top achievements
Rank 1
commented on 26 Apr 2012, 09:12 AM

And for (batch) editing? Which kind of editor template do you propose?
Alexander Valchev
Telerik team
commented on 01 May 2012, 08:34 AM

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!
Jakob Zetterström
Top achievements
Rank 1
commented on 02 May 2012, 10:43 AM

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
Alexander Valchev
Telerik team
commented on 04 May 2012, 08:11 AM

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!
Felipe Casanova
Top achievements
Rank 1
commented on 01 Jul 2012, 02:48 PM

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
Jesper
Top achievements
Rank 1
commented on 03 Jul 2012, 07:24 AM

I absolutely agree with Matt. We should not have to resort to templates to prevent the user from seeing a null value.
Alexander Valchev
Telerik team
commented on 04 Jul 2012, 02:29 PM

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!
Tim
Top achievements
Rank 1
commented on 06 Aug 2012, 11:12 PM

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.
Muhanad
Top achievements
Rank 1
commented on 07 Aug 2012, 10:12 PM

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 :)
Felipe Casanova
Top achievements
Rank 1
commented on 07 Aug 2012, 11:18 PM

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
Rodney
Top achievements
Rank 2
commented on 27 Aug 2012, 08:12 PM

So how would you do this using a row template? 
Dimo
Telerik team
commented on 28 Aug 2012, 08:42 AM

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!
Kjell Ivar
Top achievements
Rank 1
commented on 23 Oct 2012, 10:07 AM

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.

Dimo
Telerik team
commented on 23 Oct 2012, 10:48 AM

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!
Jon
Top achievements
Rank 1
commented on 02 Jan 2013, 04:04 PM

....which still does not work if the value is set via ClientTemplate.
Atanas Korchev
Telerik team
commented on 02 Jan 2013, 04:27 PM

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!
Travis
Top achievements
Rank 1
commented on 06 Mar 2013, 09:05 PM

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.
Atanas Korchev
Telerik team
commented on 07 Mar 2013, 06:53 AM

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!
Travis
Top achievements
Rank 1
commented on 07 Mar 2013, 03:14 PM

My mistake.  I'm using an older version for the Kendo UI controls.  I confused this with another project I was working on.  Sorry!
Brady
Top achievements
Rank 1
commented on 09 Jun 2013, 11:15 AM

That second example (Q1 2013 beta version) is utterly useless. It doesn't show the column or template definition.
Tags
Grid
Asked by
Tak
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or