Results 1 to 2 of 2

Thread: Set text of HTML button conditionally in grid row

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,508

    Set text of HTML button conditionally in grid row

    I have a DevExpress Blazor DxGrid on my web page which displays n rows of data. One of the columns in the grid is a status. If the status is SS I want a button next to it with caption IP. If the status is IP I want the caption to be PP. I don't know how to conditionally set this. I am new to web programming but am pretty sure this is specific to HTML, not DX, but because the buttons lie in the context of the DxGrid, I am not sure where to look for an answer. Thank you for any help, even if it's what string to put in a search engine that would lead me to the right source of information.

    Code:
        <DxGrid Data="@empTasks" PageSize="25"
                CssClass="mw-1100">
            <Columns>
                <DxGridDataColumn Caption="Status" FieldName="TripStatus" Width="50px" />
    
                <DxGridDataColumn FieldName="TripStatus" AllowSort="false" Width="70px" TextAlignment="GridTextAlignment.Left">
                    <CellDisplayTemplate>
                        <button 
                            class="btn btn-link grid-btn-link" @onclick="() =>StatusButtonClicked()">IP or PP???
                        </button>
                    </CellDisplayTemplate>
                </DxGridDataColumn>
            </Columns>
        </DxGrid>
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    Driving a 2018 Mustang GT down Route 8
    Posts
    4,508

    Re: Set text of HTML button conditionally in grid row

    I got it! Sorry for the unncessary post. I usually try to find an answer, post here, and keep looking. I kept looking and this worked:
    Code:
                <DxGridDataColumn FieldName="TripStatus" AllowSort="false" Width="70px" TextAlignment="GridTextAlignment.Left">
                    <CellDisplayTemplate>
                        @if ((string)context.Value == "SS")
                        {
                            <button 
                            class="btn btn-link grid-btn-link" @onclick="() =>StatusButtonClicked()">IP
                            </button>
                        }
                        else
                        {
                            <button 
                            class="btn btn-link grid-btn-link" @onclick="() =>StatusButtonClicked()">PP
                            </button>
                        }
                    </CellDisplayTemplate>
                </DxGridDataColumn>
    There are 10 kinds of people in this world. Those who understand binary, and those who don't.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width