Telerik Forums
UI for ASP.NET MVC Forum
7 answers
371 views
Hi,

I have a grid with editing set to popup. The model bound to the grid has a user defined field object (consisting of an ID and description) with its own custom editor (created in the shared folder) as 2 dropdownlists cascaded. (example the grid has a field called car which is composed of manufactureID and manufactureDescription and modelID and modelDescription)

I have two issues:
1- I am not able to get the data selected from any of the dropdownlists to be passed correctly to the user defined field of the grid. It always returns null.
2- How can i use cascaded dropdownlists for "dropdownlistsfor" knowing that the name property for this dropdownlist is becoming complicated as shown by firebug for example car_manufactureID-listbox. Changing the cascade property to this name doesn't link to the dropdownlist but when specifing another name the cascade feature is working.

I believe that my issue might be in the name of the dropdownlist but it is not working even when i remove the dropdownlist name completely


Best regards,
Sameh
Vladimir Iliev
Telerik team
 answered on 28 Feb 2013
1 answer
238 views
Hi,

I'm using a Kendo grid with MVC. The grid is in batch editing mode using Open Access.
One of the requirements is the possibility to undo an accidental row delete while editing. The delete confirmation is not enough.
When a user edits a lot of rows and accidentally deletes a row, the only option is to cancel the changes. However all changes in the grid are rolled back. 

I have implemented a simple undo by hiding the row in the grid and saving the dataitem in a javascript queue.In a SaveChanges event I pop the remaining items on the undo queue and programmatically delete the items.

However if the user changes the filter options of the grid the 'hidden' deleted rows become visible again as the filtering options also hides and unhides rows.

Anyone have an idea for implementing a row undo that survives filtering and sorting ?

Regards,
Marcel
Daniel
Telerik team
 answered on 28 Feb 2013
1 answer
248 views
Hi, i have three questions:
1)
i have a grid as follows:

Html.Kendo().Grid<CustomerModel>()
 .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.Name);
        columns.ForeignKey(p => p.StateId, (IEnumerable)ViewData["States"], "Id", "Name").Filterable(true).Title("State");
        columns.Command(command => { command.Edit(); command.Destroy(); });// edit/insert and delete buttons
    })

I want to be able to to trigger all actions by keyboard. While it works on the input fields, it seems i cannot use the Tabulator Key to traverse my buttons.

2)
 I want to be able to save rows by hitting the "enter" key on my keyboard. This should work when the cursor is somewhere in the row. This is a problem when i have controls like combobox or datepicker inside my row because there you use the "enter" key to select entries. Is there a way to only bubble the keyup event to the row when the dropdownbox'/datepicker's state is != open? (it should only bubble the event when the enter key is hit while i am not selecting a value).

3)
The above mentioned column for the stateID is of type long? (nullable). I already found out that there is a problem when i want to insert a new line because the combobox tries to set the value to the whole object - not only the null value. Is there an official solution to this problem, because like this, the control is not really useable .... (even though you said in another thread that this is the intended behaviour).

best regards,
daniel
Petur Subev
Telerik team
 answered on 28 Feb 2013
4 answers
135 views
The combobox only seems to post its value if the property is of type string when it's in a grid popup window.  In my case i'm using ServerFiltering(true) on the combobox.  The value should be a long and the property is a long, but unless i make the property a string the value will not post. 

Attached a sample project.

Sorry if this is repeated somewhere, I searched for a while.

Thanks.
Chris
Top achievements
Rank 1
 answered on 27 Feb 2013
3 answers
238 views
Hello,
here's the part of the code from the template...
@(Html.Kendo().DropDownListFor(model => model.EmailType)
          .Name("EmailType")
          .BindTo(Enum.GetNames(typeof (EmailTypeEnum)).ToList())
                 )

When the popup is shown from an edit command, the value that is selected does not show in the grid after I click "Update". I can see the orange indicator that the fields is being edited in the grid, but the value is not shown.
If I do need to use a datasource object, can I use emuns as the underlying data type? If so please show an example.

Thanks

 

 

 

 

 

 

)

Petur Subev
Telerik team
 answered on 27 Feb 2013
1 answer
189 views
Hi all,
I bought two days full telerik controls.
But I made ​​no example of a mobile application with ASP.NET MVC Razor could not find.
Please Please help me in this regard.
Tablet and Mobile applications to run in ASP.Net MVC Razor I want to do.
Do you have sample application in the hands of the
Alexander Valchev
Telerik team
 answered on 27 Feb 2013
5 answers
252 views
I just burned up 10 hours of a 100 hour budget trying to get the tree view to bind to an XML file. None of your examples worked! So then I tried the remote binding, which did actually work, as long as I transformed the XML into a class for the JSON return. Well, I can deal with transforming the XML document into a class, but the hierarchical part does not work at all. The tree just repeats the original root items over and over again.

I am including code for the classes that I am trying to use, which includes the base class and a second class with would be the second tier (I won't actually need 2 classes in the end). I have also included the controller code and the view code.

Please, please help, my time is running low and I promised to get this done using your stuff!!!!!

Here is the tree result. As you can see the root items are just repeated over and over. The item that is a child of "you" never shows up

you
  • you
    • you
      • you
        • you
          • you
            • you
            • me
          • me
        • me
      • me
    • me
  • me
  • me

  • My Classes
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
     
    namespace MCFD.MobilePolicy.MVC.Models
    {
        public class SiteStructure
        {
            public SiteStructure()
            {
     
            }
            private List<string> next;
            private string myName = "N/A";
            private List<InnerStructure> colHasChildren;
            private int ID;
     
            // Declare a Name property of type string:
            public string Name
            {
                get
                {
                    return myName;
                }
                set
                {
                    myName = value;
                }
            }
     
            public int id
            {
                get
                {
                    return ID;
                }
                set
                {
                    ID = value;
                }
            }
            //public bool HasChildren
            //{
            //    get
            //    {
            //        return hasChildren;
            //    }
            //    set
            //    {
            //        hasChildren = value;
            //    }
            //}
            public List<InnerStructure> hasChildren
            {
                get
                {
                    return colHasChildren;
                }
                set
                {
                    colHasChildren = value;
                }
            }
        }
     
     
        public class InnerStructure
        {
            public InnerStructure()
            {
     
            }
            private List<string> next;
            private string myName = "N/A";
            private List<InnerStructure> colHasChildren;
            private int ID;
     
            // Declare a Name property of type string:
            public string Name
            {
                get
                {
                    return myName;
                }
                set
                {
                    myName = value;
                }
            }
     
            public int id
            {
                get
                {
                    return ID;
                }
                set
                {
                    ID = value;
                }
            }
            //public bool HasChildren
            //{
            //    get
            //    {
            //        return hasChildren;
            //    }
            //    set
            //    {
            //        hasChildren = value;
            //    }
            //}
            public List<InnerStructure> hasChildren
            {
                get
                {
                    return colHasChildren;
                }
                set
                {
                    colHasChildren = value;
                }
            }
        }
    }

    My Controller
    public JsonResult Employees(int? id)
           {
               //ulitimate goal is to transform this xml into a structure for the tree. I will deal with this later. Note that none of the bind to xml methods have worked for me.
               XElement xml = XElement.Load(Server.MapPath("~/App_Data/books.xml"));
              
               //Create 2 items for the tree
               Models.SiteStructure sitemapitem = new Models.SiteStructure();
               sitemapitem.Name = "you";
               sitemapitem.id = 1;
               Models.SiteStructure sitemapitem2 = new Models.SiteStructure();
               sitemapitem2.Name = "me";
               sitemapitem2.id = 2;
     
               //Create hierarchy by adding a new list to the first item in the root of items
               Models.InnerStructure sitemapitem3 = new Models.InnerStructure();
               sitemapitem3.Name = "why does this not work?";
               sitemapitem3.id = 3;
     
               List<Models.InnerStructure> sitemap2 = new List<Models.InnerStructure>();
               sitemap2.Add(sitemapitem3);
               sitemapitem.hasChildren = sitemap2;
     
               //Add the items to list of items to return
               List<Models.SiteStructure> sitemap = new List<Models.SiteStructure>();
               sitemap.Add(sitemapitem);
               sitemap.Add(sitemapitem2);
     
               return Json(sitemap, JsonRequestBehavior.AllowGet);
           }

    My View
    <div class="demo-section">
        @(Html.Kendo().TreeView()
            .Name("treeview")
            .DataTextField("Name")
            .DataSource(dataSource => dataSource
                .Read(read => read
                    .Action("Employees", "SiteEditor")
                )
            )
        )
     
       
     
    </div>

    Daniel
    Telerik team
     answered on 27 Feb 2013
    8 answers
    290 views
    Hello again,
    I have installed on my computer in Visual Studio 2010 more templates:Kendo UI for MVC Web application,Telerik MVC 3 Web Application(Razor),Telerik MVC 4 Web application(RAzor)
    we would like to start a project using web controls with mvc(razor),which one is the latest or appropiate to use .
    Or what template in Visual Studio corespond to Kendo UI Complete for MVC as a part of DevCraft Tools ?

    Regards,
          Daniel
    Daniel
    Top achievements
    Rank 1
     answered on 27 Feb 2013
    6 answers
    587 views
    Hello,

    I am new to MVC and I am attempting to use the GRID to perform functions as I have in the past with the ASP.NET AJAX controls.  I am using Entity Framework for my model and I have a controller in place.  I have the grid in my view and I have it successfully pulling the data from the model to display but the Add, Edit, Delete functions are not firing properly.  Whenever I hit any of those buttons it tries to go to the URL that I believe would be associated if I were not using the grid.

    For example when I hit the edit button instead of opening the popup form it goes to: /Grid/Index/2?gvBeamlines-mode=edit which of course throws a 404 error.  The add button goes here: /Grid?gvBeamlines-mode=insert and the delete button goes here: /Grid/Delete/2

    The URL of the initial view with the grid is /Beamlines so why is it going to /Grid instead?  None of the methods in the controller seem to be firing.  I feel like I am missing some basic piece to make this work.  My code looks very similar to the demo code so I'm not sure what is wrong.  Any help would be appreciated.  The view and controller code is below.

    View:
    @model IEnumerable<MyLibrary.Beamline>
     
    @{
        ViewBag.Title = "Beamlines";
    }
     
    <h2>Beamlines</h2>
     
    @(Html.Kendo().Grid(Model)
        .Name("gvBeamlines")
        .Columns(columns =>
        {
            columns.Command(command => { command.Edit(); }).Width(50);
            columns.Bound(o => o.Description).Width(100);
            columns.Bound(o => o.Insertion_Device).Title("Insertion Device");
            columns.Bound(o => o.Status);
            columns.Bound(o => o.Energy_Range).Title("Energy Range");
            columns.Command(command => { command.Destroy(); }).Width(50);
        })
        .ToolBar(toolbar => toolbar.Create())
        .Editable(editable => editable.Mode(GridEditMode.PopUp))
        .Pageable()
        .Sortable()
        .DataSource(dataSource => dataSource
            .Server()
            .Model(model => model.Id(o => o.ID))
            .Create(create => create.Action("Create", "Grid"))
            .Read(read => read.Action("Index", "Grid"))
            .Update(update => update.Action("Edit", "Grid"))
            .Destroy(destroy => destroy.Action("Delete", "Grid"))
        )   
    )



    Controller: (only some methods are in place so far)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    using MyLibrary;
     
    namespace MyProject.Controllers
    {
        public class BeamlinesController : Controller
        {
            //
            // GET: /Beamlines/
     
            public ActionResult Index()
            {
                using (MyEntities context = new MyEntities())
                {
                    return View(context.Beamlines.ToList());
                }
            }
     
            //
            // GET: /Beamlines/Details/5
     
            public ActionResult Details(int id)
            {
                return View();
            }
     
            //
            // GET: /Beamlines/Create
     
            public ActionResult Create()
            {
                return View();
            }
     
            //
            // POST: /Beamlines/Create
     
            [HttpPost]
            public ActionResult Create(Beamline beamline)
            {
                try
                {
                    // TODO: Add insert logic here
     
                    return RedirectToAction("Index");
                }
                catch
                {
                    return View();
                }
            }
             
            //
            // GET: /Beamlines/Edit/5
      
            public ActionResult Edit(int id)
            {
                using (MyEntities context = new MyEntities())
                {
                    var beamline = context.Beamlines.Single(p => p.ID == id);
                    return View(beamline);
                }
            }
     
            //
            // POST: /Beamlines/Edit/5
     
            [HttpPost]
            public ActionResult Edit(int id, FormCollection collection)
            {
     
                using (MyEntities context = new MyEntities())
                {
                    var beamline = context.Beamlines.Single(p => p.ID == id);
                    TryUpdateModel(beamline);
                    if (ModelState.IsValid)
                    {
                        context.SaveChanges();
                        return RedirectToAction("Index");
                    }
                    return View(beamline);
                }
            }
     
            //
            // GET: /Beamlines/Delete/5
      
            public ActionResult Delete(int id)
            {
                return View();
            }
     
            //
            // POST: /Beamlines/Delete/5
     
            [HttpPost]
            public ActionResult Delete(int id, FormCollection collection)
            {
                try
                {
                    // TODO: Add delete logic here
      
                    return RedirectToAction("Index");
                }
                catch
                {
                    return View();
                }
            }
        }
    }
    Dimo
    Telerik team
     answered on 27 Feb 2013
    1 answer
    147 views
    Hi ,

    I have a problem with validation for dropdown on click of submit. The validation triggers in Chrome but IE9 doesnt support, so could any one suggest a work around for IE.

    Here is the dropdown UI

    <div id="ModalMaterialCodeMappingForm">
        <div class="editor-row" style="padding-bottom: 1em;">
            <div class="selector-type-column">
                @(Html.Kendo().DropDownList().Name("editMappingTerminalSearchTypeDropDownList")
                      .DataTextField("Text").DataValueField("Value").BindTo(Model.TerminalSearchType))
            </div>
            <div class="float-left editor-label" style="width: 80px;">
                @Html.LabelFor(model => model.TerminalName)
            </div>
            <div class="float-left">
                @Html.TextBoxFor(model => model.TerminalName, new {selectedValue = "0", @class = "selector"})&nbsp;<span  style="color:red">*</span><span class="k-invalid-msg" data-for="TerminalName"></span>
            </div>
            <div class="clear"></div>
        </div>

    the dropdown is an autocomplete which has a placeholder, if i remove the place holder the validation triggers.

    textBoxField.kendoAutoComplete({
            minLength: 1,
            dataTextField: "Value",
            dataValueField: "Key",
            filter: "contains",
            placeholder: placeHolderText
    });


    I have attached the screenshots.
    Daniel
    Telerik team
     answered on 26 Feb 2013
    Narrow your results
    Selected tags
    Tags
    +? more
    Top users last month
    Jay
    Top achievements
    Rank 3
    Bronze
    Iron
    Iron
    yw
    Top achievements
    Rank 2
    Iron
    Iron
    Stefan
    Top achievements
    Rank 2
    Iron
    Iron
    Iron
    Kao Hung
    Top achievements
    Rank 1
    Iron
    Bohdan
    Top achievements
    Rank 2
    Iron
    Iron
    Iron
    Want to show your ninja superpower to fellow developers?
    Top users last month
    Jay
    Top achievements
    Rank 3
    Bronze
    Iron
    Iron
    yw
    Top achievements
    Rank 2
    Iron
    Iron
    Stefan
    Top achievements
    Rank 2
    Iron
    Iron
    Iron
    Kao Hung
    Top achievements
    Rank 1
    Iron
    Bohdan
    Top achievements
    Rank 2
    Iron
    Iron
    Iron
    Want to show your ninja superpower to fellow developers?
    Want to show your ninja superpower to fellow developers?