Options.Label.Render

Options.Label.Render

shuminliushuminliu Posts: 14Questions: 6Answers: 0
edited March 2020 in Editor

Hi, Allan,

In the Editor Edit popup, I'm trying to make a dropdown to show a list of stores: the list has value from Store.Number, and I'd like to have the label as Store.Name + ", " + Store.City + ", " + Store.State.

var editor = new Editor(db, "Store", "Number")
                    .Model<Store>("Store")
                    .Field(new Field("StoreNumber")
                        .Options(new Options()
                            .Table("Store")
                            .Value("Number")
                            .Label(new[] { "Name", "City", "State" })
                        )
                    )

It seems there is a Render function I could use: .Label(....).Render(...). The Render takes Func<Dictionary<string, object>, string>. I'm wondering if you could show me an example. I'm using the .NET lib.

Thanks!

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

This question has an accepted answers - jump to answer

Answers

  • rf1234rf1234 Posts: 2,991Questions: 87Answers: 421
    Answer ✓

    There is an example for "Render" in here:
    https://editor.datatables.net/manual/net/joins#Options

  • shuminliushuminliu Posts: 14Questions: 6Answers: 0

    Thanks a lot! I was in the "neighborhood" of the doc but didn't jump in "joins" :)

    For other readers' convenience, here is the code:

    var editor = new Editor(db, "Store", "Number")
                        .Model<Store>("Store")
                        .Field(new Field("StoreNumber")
                            .Options(new Options()
                                .Table("Store")
                                .Value("Number")
                                .Label(new[] { "Name", "City", "State" })
                                .Render(row => row["Name"]+ ", " + row["City"] + ', ' + row["State"]);
                            )
                        )
    
This discussion has been closed.