jay_optum
jay_optum

Reputation: 3

Issue with Kendo ToDataSource(request) build error

Simple stuff, trying to get an idea on how this works. I am missing something obvious. I have the kendo.mvc referenced correct vers. I am getting

System.Collections.Generic.List<SessiondataDTO>' does not contain a definition for 'addTestSessiondata' and no extension method 'addTestSessiondata' accepting a first argument of type 'System.Collections.Generic.List<SessiondataDTO>' could be found

using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;

Model class

public class SessiondataDTO
{
    public string userID { get; set; }
    public string serverName { get; set; }
    public string applicationName { get; set; }
    public string farmName { get; set; }
    public string domainName { get; set; }
    public int sessionID { get; set; }
    public string resultmsg { get; set; }
    public bool isInError { get; set; }
    public int id { get; set; }

    public List<SessiondataDTO> addTestSessiondata()
    { 
        List<SessiondataDTO> sessiondatas = new List<SessiondataDTO>();

        sessiondatas.Add(new SessiondataDTO { userID = "jayc", applicationName = "testapp1", domainName = "MS", farmName = "testfarm1", serverName = "wtxw0000", sessionID = 12 });
        sessiondatas.Add(new SessiondataDTO { userID = "jayc", applicationName = "testapp44", domainName = "MS", farmName = "testfarm1", serverName = "wtx44444", sessionID = 19 });
        sessiondatas.Add(new SessiondataDTO { userID = "jayc", applicationName = "testapp99", domainName = "MS", farmName = "testfarm1", serverName = "wtxw00890", sessionID = 10 });
        sessiondatas.Add(new SessiondataDTO { userID = "jayc", applicationName = "testapp1", domainName = "MS", farmName = "testfarm1", serverName = "wtxep0000", sessionID = 45 });           
        return sessiondatas;
    }

Controller

public class HomeController : Controller
{
    public ActionResult JLO()
    {
        return View();
    }

    public ActionResult sessions_read([DataSourceRequest] DataSourceRequest request)
    {
        List<SessiondataDTO> sdto = new List<SessiondataDTO>();

        sdto.addTestSessiondata();

        DataSourceResult result = sdto.ToDataSourceResult(request,);

        return Json(result, JsonRequestBehavior.AllowGet);
    }
}

Everything builds fine but I keep getting that error. I am using a simple List<> and trying to use the extension method.

Upvotes: 0

Views: 39

Answers (1)

Steve Greene
Steve Greene

Reputation: 12324

addTestSessiondata is not an extension method, but you are attempting to use it as such. Try:

public ActionResult sessions_read([DataSourceRequest] DataSourceRequest request)
{
    List<SessiondataDTO> sdto = addTestSessiondata();

    DataSourceResult result = sdto.ToDataSourceResult(request);

    return Json(result, JsonRequestBehavior.AllowGet);
}

Upvotes: 1

Related Questions