Options.Label.Render

Options.Label.Render

shuminliushuminliu Posts: 4Questions: 2Answers: 0
edited March 20 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: 1,180Questions: 48Answers: 161
    Answer ✓

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

  • shuminliushuminliu Posts: 4Questions: 2Answers: 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"]);
                            )
                        )
    
Sign In or Register to comment.