Country/State/City

The Tree control makes it easy to create a control based on hierarchical data. Simply define the source of the data for each level and the relationship between the data at each level using the PrimaryKey and ForeignKey properties

Loading...
Razor code

    var citySelect = new TreeModel("cities") ;
    citySelect.Columns = new List
    {
        new TreeColumn("cityid") {PrimaryKey = true },
        new TreeColumn("cityname"),
        new TreeColumn("stateid") { ForeignKey = true }
    };

    var stateSelect = new TreeModel("states") ;
    stateSelect.Columns = new List
    {
        new TreeColumn("stateid") {PrimaryKey = true },
        new TreeColumn("statename"),
        new TreeColumn("countryid") { ForeignKey = true}
    };
    stateSelect.NestedLevel = citySelect;

    var countrySelect = new TreeModel(DataSourceType.SQLite, "DbNetSuiteCore", "countries");
    countrySelect.Columns = new List
    {
        new TreeColumn("countryid") {PrimaryKey = true },
        new TreeColumn("countryname")
    };
    countrySelect.NestedLevel = stateSelect;
    countrySelect.SelectionTitle = "Selected City";
    countrySelect.FixedFilter = "countryname in ('United Kingdom','Ireland')";
    countrySelect.Search = true;
    countrySelect.Expand = true;
    countrySelect.Bind(TreeClientEvent.ItemSelected,"showSelectedCity");

    <div style="display:flex;flex-direction:column;gap-4">
        <div>
            @(await DbNetSuiteCore.Control.Create(HttpContext).Render(countrySelect))
        </div>
    </div>