Developer forum

Forum » Feature requests » Add sort order for GridRowViewModel

Add sort order for GridRowViewModel

Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi guys,

Sometimes it would be helpful to know the position of the grid on the page.

In my situation specifically, I need to know if it is the first GridRow on the page. But it can be useful to see the position of the grid rows and if it;'s the first or the last GridRow on the page ("IsFirst" and "IsLast").

Something like this:
 

{
    "Id": 6953,
    "SortOrder": 1,
    "IsFirst": true,
    "IsLast": false,
    "Definition": {
        "Id": "2Columns",
        "Name": "2 Columns",
        "Description": "1 row with 2 columns",
        "Template": "2Columns.cshtml",
        "ColumnCount": 2,
        "ItemType": "Swift_2Columns",
        "Thumbnail": "/Files/Templates/Designs/Swift/Assets/Images/VisualEditor/DW_Row_2-column.svg"
    },
....
}

I hope this makes sense.

Thank you,

Adrian


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Adrian

Can you provide some context - what is the use case? Trying to understand to ensure a proper implementation

BR Nicolai

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

And you can always do something like this:

bool firstRowRendered = Dynamicweb.Context.Current.Items.Contains("firstRowRendered");
if (!firstRowRendered) { Dynamicweb.Context.Current.Items.Add("firstRowRendered", true); }
 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

In my situation, I need to include breadcrumb information in the first row of the page.
I can't use separate rows, because it has to be incorporated into a row with a specific background.
Something like this:

If I have this info on the row, I can customize the template of the row to include the info.

For now, I have managed to get the info with Dynamicweb.Content.Services.Grids.GetGridById(gridId).Sort

But, I was thinking that this info is already available when you create the Model and may optimize the performance a bit by avoiding a separate call.

It can be something similar for the last Grid on the page. For example, you may need to apply a specific style (or theme) for the last element on the page to better separate it from the footer.

Thank you,

Adrian

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

The workaround I provided is pretty simple.

All kind of styling can be done with regular css selectors, i.e. 

.my-row-container .my-row:first-of-type,
.my-row-container .my-row:last-of-type{
    background-color:red;
}

But it has been noted down.

Thanks for clarifying.

 
Adrian Ursu Dynamicweb Employee
Adrian Ursu
Reply

Hi Nicolai,

Thank you.


Adrian