Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Do I need to define the schema? If so, what should that look like? My searches for this seem to only turn up js solutions, I'm looking for the syntax to define it in the editortemplate.

Shared/editortemplate:

C#
@(
Html.Kendo().DropDownList()
.Name("SearchFunction")
.DataTextField("SearchFunctionDesc")
.DataValueField("SearchFunctionCode")
.DataSource(source =>
    {        
        source.Read(read => { 
            read.Action("GetSearchFunctions", "User");
        });
    })
    .OptionLabel("--Select a Search Function--")
    .AutoBind(false)
)


In the user controller:

C#
public JsonResult GetSearchFunctions([DataSourceRequest] DataSourceRequest request)
{
    var searchFuncs = cmsViewAdminService.GetSearchFunctions();
    DataSourceResult result = searchFuncs.ToDataSourceResult(request);
    return Json(result, JsonRequestBehavior.AllowGet);
}


And then my Dapper db query:

C#
var result = new List<SearchFunction>();
using (var conn = new OracleConnection(DatabaseConnectionString))
{
    conn.Open();
    string query = "select FUNCTION_ID, SEARCH_FUNCTION_CD, " +
            "SEARCH_FUNCTION_DESC, IS_ACTIVE " +
             "from TBL_SEARCH_FUNCTIONS ";
    result = conn.Query(query)
        .Select(s => new SearchFunction
        {
            FunctionId = (int)s.FUNCTION_ID,
            SearchFunctionCode = s.SEARCH_FUNCTION_CD,
            SearchFunctionDesc = s.SEARCH_FUNCTION_DESC,
            Active = s.IS_ACTIVE
        }).ToList<SearchFunction>();
    conn.Close();
    return result;
}
Posted

1 solution

 
Share this answer
 
Comments
Richard Deeming 17-Feb-16 8:53am    
It's good that you've solved your own question, but it would be better if you copied the relevant details to your solution, rather than relying on a link to an external site. If the site goes down, or the thread is deleted, the solution would be lost. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900