Try to search your question here, if you can't find : Ask Any Question Now ?

Kendo Grid changing depending on DropDownList

HomeCategory: stackoverflowKendo Grid changing depending on DropDownList
gaurav asked 2 weeks ago

Before I start I’ll just say that I’ve looked at other answers before posting and none specifically help me.

I need to create a Kendo UI grid in ASP.NET MVC that changes depending on what the users selects from a DropDownList. I will eventually be using data from a database, but currently I’m trying to learn with random hard-coded data.

I found a tutorial online that shows me how to do it with data from a sample database, but I can’t set that up for reasons I cant explain. So I’m trying to adapt the code from that tutorial to work with my controllers and models. This might be set up completely wrong as I’m relatively new to ASP.NET MVC.

So here’s the tutorial I’m trying to follow.

This is my controller:

       public class LookupValueController : Controller
        {
            private List<LookupModel> tables = new 
List<LookupModel>()
                { new LookupModel() { TableName = "Table1", 
Description = "Table 1" },
                  new LookupModel() { TableName = "Table2", 
Description = "Table 2" } };

        private List<LookupValueModel> values = new List<LookupValueModel>()
            { new LookupValueModel() { TableName = "Table1", Description = "Value 1", LookupCode = "1" },
              new LookupValueModel() { TableName = "Table2", Description = "Value 2", LookupCode = "2"} };


        // GET: LookupValue
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult GetAllTableA()
        {
            try
            {

                var table = tables;

                return Json(table, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(ex.Message);
            }

        }

        public ActionResult GetAllTableB()
        {
            try
            {

                var value = values;

                return Json(value, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(ex.Message);
            }

        }
    } 

Then my 2 models:

    public class LookupValueModel
    {
        public string TableName { get; set; }
        public string LookupCode { get; set; }
        public string Description { get; set; }
    } 

    public class LookupModel
    {
        public string TableName { get; set; }
        public string Description { get; set; }
    }

I’ve tried just changing the values in the view in the tutorial but it doesn’t work, as I believe it isn’t as simple as just changing some text.

I’m pretty stuck for how to do this and don’t know where to go from here. I know this is a very long winded post with lots of code, but I would really appreciate some help.

Where am I going wrong adapting the tutorial code? What do I have to change to get it to work with hard-coded data?

1 Answers
Best Answer
Matthias answered 2 weeks ago
Your Answer

6 + 20 =

Popular Tags

WP Facebook Auto Publish Powered By : XYZScripts.com