Closed Dunge closed 7 months ago
Oh well I tried the idea of having two separate IGridColumnCollection, one on the server with just the .Add() and .Titled() statements, and one on the client with the additional .RenderValueAs() and .RenderComponentAs() statements. And it seems to be working.
Please advise if there's anything wrong with doing it that way.
Column definitions must not be the same on both client and server sides. But must be compatible, including all "connected" columns with the same name. The server side performs all filtering, sorting, searching, totals calculation. So for those columns that will be filtered, sorted, etc. the column definition must be the same, except the methods used for rendering the column on client side.
Columns defined a "not connected" using .RenderValueAs() and .RenderComponentAs() statements can be excluded on the server side columns definition.
I use a static definition on the samples because it was easier and avoids mistakes.
But there is a sample where column definitions are diferent on each side (https://github.com/gustavnavar/Grid.Blazor/tree/master/GridBlazorJava). It is a Blazor WASM client project where the server side is executed on a Java project (https://github.com/gustavnavar/Grid.Java.Core/tree/master/demo). This Java server project uses the GridJavaCore library (https://github.com/gustavnavar/Grid.Java.Core), a migration of GridCore library for Java environments. In this sample the column definitions are different, but they are compatible between them.
Thank you
I'm sorry this is more of a question than a bug report. I'm probably just misunderstanding something, I would like clarification on how this is supposed to work.
In the project types that use GridServer (REST api and gRPC), the class requires a IGridColumnCollection func as a parameter. In the samples, this collection is declared as static and shared between projects to be used both in the client and server grid objects.
This ColumnCollection is mostly used as a way to defined the presentation on the user interface, and I wonder why the server needs it at all and don't just return the entity types?
My issue is that I would like to use RenderValueAs() to transform data using services that only exists in the client (Blazor WASM) side. For exemple, one column is an Id and the client project has a service with a Dictionary to transform it to a string, but the server doesn't, or at least does it differently. Another exemple would be a DateTime column the server query would return in UTC, but the client would transform to local time based on a locally selected timezone on the Blazor webpage the server doesn't know about. Having the columns collection static and shared prevent us from doing these kind of transformation based in client-side data only?
There's also the RenderComponentAs() that practically means the server project needs to reference the WASM project to be able to reference the component? Surely this isn't required?
Is it really the only way? Can I somehow create two column collections that are similar but would not have those renderas() method on the server-side?