-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handling null value in Grid grouping cell. #53
Comments
Hello simonssspirit, Maybe it would be simpler to add additional property for grouping descriptor. For instance (using typescript): } |
Additionally, nullValue may be not only string. It may contain value with toString method (again typescript): } |
@Roamel We plan to detach the Since they will be detached, passing configuration to the descriptors does not mean it will be accessible/matched to the actual group header/footer. The group footers and headers on the other hand are direct representation of the group items in the data and could be used as configuration as well. I think the more suitable solution is removing the problematic type casting. Comes with the following benefits:
Update: this change can be tested here: https://stackblitz.com/edit/react-cthaqt?file=app%2Fmain.js |
Look good. However I am interesting about formatting |
What about this way (isPrimitiveType, format and fieldFormat just a pseudo code): |
Ah, it looks like, finally, I have got your idea:
I like this approach |
@Roamel , @telerik/kendo-react-team , @rkonstantinov any suggestions where the configuration for the format should be placed. I am opened for all kind of ideas. If we check the type of the data and apply some predefined format culture and locale(as in your suggestion), you would need to be able to change the format. And here is the problem:
Based on the above, we can't put configuration options for the group headers into the column declaration that the user defines. Because there is non one to one match between them. An option is to add separate configuration for the formats, that to be passed down to the GroupCell, but it should be matched by something and that can't be the Here is an example. Runnable version here https://stackblitz.com/edit/kendo-grid-sync-xktxqj?file=index.tsx class App extends React.Component<{}, {}> {
readonly state = {
dataResult: {
total: 2,
data: [
{
value: 'This is the first group',
items: [
{ a: new Date(), b: new Date(2010, 10, 10) },
{ a: new Date(), b: new Date(2010, 10, 10) }]
},
{
value: 55, //This is the second group, but have different type of the value
items:
[{ a: null, b: 'yet another type' }]
},
{
value: new Date(), // The third group
items: [
{ a: new Date(), b: 1234 },
{ a: new Date(), b: null }]
}
]
}
}
render() {
return (
<Grid
data={this.state.dataResult}
group={[{ field: '' }]} // you would be able to remove that when #41 got fixed
reorderable={true}
>
<GridColumn field="a" format="{0:dd MM yyyy}" />
<GridColumn title="some column without type" field="b" />
<GridColumn title="a with different format" field="a" format="{0:yy-MM-dd-hh-mm-ss}" />
</Grid>);
}
} I think the above illustrates the problem of specifying any format for the groups. So if we need to keep the grid flexible for showing different kind of data without restrictions, it is best if we treat the group data items value as "Label" rather than "Value". It is easy for the user to decide if he wants to format them before passing down to the grid. (more over he could already do that) If the issue is with the |
Removing toString in
Additionally we want to reuse format for group item values and grid columns. If you able to provide extension method that doing similar logic as above it would be helpful. |
Since it does not throw error I am removing the bug item now, some documentation need to be improved for custom formatting and then we can close this |
This is another approach to change the value, using cellRender and modifying the children prop. |
Currently, if the Grid has a null value inside the grouped column an error will be shown in the console as the null values do not have a toString method.
There are three approaches which we can take:
Leave the current behavior and pre-process the data to convert the null values or to use a cell renderer to display the null values as desired by the developer.
Automatically convert the null value to empty string when showing it inside the grouping row. The downside of this approach is that if there are actual values with an empty string, then two separate groups with the same grouping row will be shown requiring cell render to change the value of one of them.
Show the null value as string null. The downside is that the null string is not a value that can be helpful to the end user thus requiring to overwrite it with a cell render.
All approaches may require cell renderer at the end, but some of the approaches will require it only in specific cases.
Please share your feedback and suggestion for another approach if it comes to mind.
cc/ @telerik/kendo-react-team
The text was updated successfully, but these errors were encountered: