Default onload sort for Datagrid

Hi Radzen Team

I am having an issue that i canot solve.

I am trying to get the datagrid to sort by the description column when the grid first loads.
I cannot seem to get it right.

I have tried ${event.orderby || 'description desc'} but i get an error:
"error CS1012: Too many characters in character literal"

What am i doing wromg or is there another way?

Check this demo:

Thank you for the swift reply.

How would i implement this within the radzen desktop application?
From what i see the pages a regenerated each time.

C# strings use double quotes. Try ${event.orderby || "description desc"} and make sure the property casing is correct e.g. the property is called description and not Description.

I did try ${event.orderby || "description desc"} also and i get 2 errors from this format.

error CS0019: Operator '||' cannot be applied to operands of type 'string' and 'string'

error CS0428: Cannot convert method group 'Count' to non-delegate type 'int'. Did you intend to invoke the method?

It seems to malform the code with the double quotes, hence the second error.

This code is for Angular, you can check this article for another option with Blazor:

I have tried this, this is the same as my initial post. It thorws an exception even with the double quote.

Hey @DarrenW,

Not sure what in the post I linked is like your initial post. This code ${event.orderby || 'description desc'} is not C#, it's a JavaScript expression used in Angular Radzen application. The post I linked shows how to set $orderby parameter for data source method invoke and again to restate the options:

  • you can use column SortOrder property to define the initial column sort order
  • you can sort your data using the $orderby parameter