Rami Yusf
Rami Yusf

Reputation: 3022

Bind Kendo grid to CSV text

I'm using Telerik UI for ASP.Net MVC and I want to know how can I convert my model to CSV text and bind it to Kendo grid it will be more light than JSON while transfer data to the client.

Upvotes: 0

Views: 207

Answers (1)

Adrian Salazar
Adrian Salazar

Reputation: 5319

I understand your concern, and I was actually doing the same things on my projects, trying to optimize the extra bytes from the JSON sent back to the client.

Turning something like this:

{
    status: true,
    data: [
        { name: 'aaa', lastName: 'ln1', identifier: 124343 },
        { name: 'bbb', lastName: 'ln2', identifier: 887875 },
        { name: 'ccc', lastName: 'ln3', identifier: 445455 }
    ]
}

Into this:

{
    s: 1,
    d: [
        { n: 'aaa', l: 'ln1', i: 124343 },
        { n: 'bbb', l: 'ln2', i: 887875 },
        { n: 'ccc', l: 'ln3', i: 445455 }
    ]
}

I got a shameful 10% savings by tweaking the JSON message and adjusting my client code (translate: overhead).

After a few analysis of my HTTP traffic I realized that GZIP compression was supported by the browser, the request headers of any decent browser include "Accept-Encoding: gzip, deflate" but somehow my server was totally ignoring this thing because there was no response header saying "Content-Encoding: gzip".

You can verify this by checking the request and response headers, see picture.

Verifying gzip encoding on Firebug

So after I forced the server to encode the content with GZIP compression if the client supports it, the network savings dropped to 80% of size.

GZIP compression is: - Fast on the server - Easy on the client - You can choose where to activate it or not (let's say use it on responses that you know that will return a big amount of items) - Benefits from repetitive text contents (as it uses a dictionary approach)

So believe me, the don't worry about how the JSON looks, use GZIP. I had to revert all of my overhead code afterwards.

Upvotes: 1

Related Questions