Telerik Forums
UI for ASP.NET MVC Forum
5 answers
82 views
anyone know if the autocomplete control is capable of grouping?
Petur Subev
Telerik team
 answered on 11 Feb 2014
1 answer
89 views
So I've been reading, that AutoComplete does not have a value property. Is this true? If so, why not. I was forced to use a multicomplete field and set the MinValue to 1
in order to get the job done. Also, can anyone explain the difference between .Template and .ClientTemplate
Alexander Popov
Telerik team
 answered on 11 Feb 2014
1 answer
426 views
I am trying to do the following:
  1. Use a Kendo UI Grid
  2. Have columns that have dropdowns for editors
  3. Have a re-usable method to implement those dropdowns
  4. Send the values from the grid to the server when the form posts

Here's what I've done so far:
I have the grid showing on my page and editable.  I am able to send the values from the grid to the server with the form post (using a method similar to the one shown here: http://www.telerik.com/support/code-library/submit-form-containing-grid-along-with-other-input-elements)
I have looked at the custom editor examples here (http://demos.telerik.com/kendo-ui/web/grid/editing-custom.html) and here (http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/helpers/grid/editor-templates) but this method involves creating a partial view for each dropdown.  I would prefer not to have to copy/paste/edit this code every time I need a new dropdown.  I think there should be a way to create a re-usable partial view that can perform this function.  Along these lines, I have created a small view model and partial view like what is mentioned here (https://stackoverflow.com/questions/11498215/asp-net-mvc-built-in-support-for-dropdownlist-editor-template).

Current status:
The dropdown appears in my grid as expected, and I can select a value.  I don't know how to get the text and value of the selected item so I can include them in the ClientTemplate, however.

My grid looks like this:
@(Html.Kendo().Grid<AccountManagement.Business.ViewModels.Areas.DM.RehireDocumentSettingViewModel>()
                    .Name("DocumentSettings")
                    .Columns(columns => {
                            /*
                            columns.Bound(ds => ds.FormID)
                                .ClientTemplate("#= FormID #" +
                                    "<input type='hidden' name='DocumentSettings[#= index(data)#].FormID' value='#= FormID #' />"
                                );
                            */
                            columns.Bound(ds => ds.FormsViewModel)
                                .ClientTemplate("#= 'test' #" +
                                    "<input type='hidden' name='DocumentSettings[#= index(data)#].FormID' value='#:data.Value #' />"
                                );
                            columns.Bound(ds => ds.DocumentDateTypeName)
                                .ClientTemplate("#= DocumentDateTypeName #" +
                                    "<input type='hidden' name='DocumentSettings[#= index(data)#].DocumentDateTypeName' value='#= DocumentDateTypeName #' />"
                                );
                            columns.Bound(ds => ds.RemoveIfOlderThanDays)
                                .ClientTemplate("#= RemoveIfOlderThanDays #" +
                                    "<input type='hidden' name='DocumentSettings[#= index(data)#].RemoveIfOlderThanDays' value='#= RemoveIfOlderThanDays #' />"
                                );
                            columns.Command(command => command.Destroy());
                        }
                    )
                    .ToolBar(toolbar => {
                        toolbar.Create();
                    })
                    .Navigatable()
                    .Sortable()
                    .Scrollable()
                    .Editable(editable => editable.Mode(GridEditMode.InCell))
                    .DataSource(dataSource => dataSource
                        .Ajax()
                        .Batch(true)
                        .ServerOperation(false)
                        .Events(events => events.Error("error_handler"))
                        .Model(model => model.Id(ds => ds.FormID))
                        .Read("RehireDocumentSetting_Editing_Read", "RehireSetup")
                    )
                )

The small viewmodel for my dropdown partial editor looks like this:
public class DropDownViewModel
    {
        public string SelectedID { get; set; }
        public IEnumerable<SelectListItem> Items { get; set; }
    }

My partial view looks for the dropdown editor looks like this:
@model AccountManagement.Business.ViewModels.Areas.DM.DropDownViewModel
 
@(Html.Kendo().DropDownListFor(m => m)
    .DataValueField("Value")
    .DataTextField("Text")
    .BindTo(new SelectList(Model.Items, "Value", "Text", Model.SelectedID))
    .Value("SelectedID")
)

So my question is: is there a way to fix my ClientTemplate for the FormsViewModel column so that it displays the text of the selected item when not being edited (instead of 'text' as it does now) and submits the ID of the selected item to the server?  Alternatively, is there another way to do this that meets items 1-4 at the top of this post?

Any ideas are appreciated.

Thanks,
Brian




Petur Subev
Telerik team
 answered on 11 Feb 2014
0 answers
131 views
I am developing my ASp.net MVC application using Kendoui MVC extensions. So In my form I have all the kendoui grid, dropdown, datepicker etc... I have accumulated them all in my @using(Html.BeginForm ()) But I am not sure How do i post my form data to the controller. If anybody has done that could you please shre your experience.

For example:

I have two entities: Faculty and FacultyType in My DAL

​public class Faculties
{
    public int FacultyId { get; set; }
    public string StaffNumber { get; set; }

    public int FacultyTypeId { get; set; }
    public virtual FacultyTypes FacultyTypes { get; set; }
}

public class FacultyTypes
{
    public FacultyTypes()
     {
       this.Faculties = new List<Faculties>();
      }
    public int FacultyTypeId { get; set; }
    public string FacultyTypeCode { get; set; }
    public string FacultyType { get; set; }
    public bool IsDefunct { get; set; }
    public virtual ICollection<Faculties> Faculties { get; set; }
}


I have my ViewModels in my application:

​public class ViewModelFaculty
{
    public int FacultyId { get; set; }
    public string StaffNumber { get; set; }

    public ViewModelFacultyTypes FacultyType { get; set; }
}

public class ViewModelFacultyTypes
{

    [ScaffoldColumn(false)]
    public int FacultyTypeId { get; set; }

    [Required(ErrorMessage ="Faculty Type Code is Required")]
    public string FacultyTypeCode { get; set; }

    [Required]
    public string FacultyType { get; set; }

     public bool IsDefunct { get; set; }

}

My View page having kendoui extensions for ASp.net MVC.

@using(Html.BeginForm())
{
<fieldset>
<legend class="main">Personal Particulars</legend>
<div class="view-table">
<div class="view-row">
<div class="view-name"><label for="staffId">Staff ID</label></div>
<div class="view-name"><input id ="txtStaffId" name="StaffId" class="k-textbox" data-bind="value: StaffId" type="text" required /></div>
<div class="view-name"><label for="facultyType">Faculty Type</label></div>
<div class="view-name">
@(Html.Kendo().DropDownList()
.Name("ddFacultyType")
.DataTextField("FacultyType")
.DataValueField("FacultyTypeId")
.OptionLabel("Select Faculty Type")
.Enable(true)
.AutoBind(true)
.DataSource(ds =>
{
ds.Read(read =>
{
read.Action("GetFacultyTypes", "NewFaculty");
})
.ServerFiltering(true);
})

)
</div>
</div>
}

I am showing a part of my view as if I could post two fields then rest all will be of same logic.
So now when I submit my form I need to post the data in the form to controller.
Even kendoUi website as also not given any end to end example of how to use the extensions in a form and how to post the data.

If anyone has been working in same enviorment or any direction on how to do please suggest me.

Steve
Top achievements
Rank 1
 asked on 11 Feb 2014
6 answers
354 views
We are trying the trial version to determine if we are going to purchase it but my testing has run into a problem. I am trying to load a data source in JavaScript so that will be called when a id from the treeview is passed on selection ( that part is working) , but when I call my java script function the data source creates but no data is returned, I have included my JavaScript function here and I have also included the method from the controller it is to call, can someone tell me why I get no data back, i have created an alert at the end of the function to show the data but the length is always zero for the loop does not execute

here is the JavaScript

    var updateAgencySystemInfo = function (agencyId, agencySystemModel) {
        var ds = new kendo.data.DataSource({
            trasnport: {
                read: {
                    type:"POST",
                    url: "/Administrator/GetAgencySystemInfo",
                    contentType: "application/json; charset=utf-8",
                    dataType: "json"
                },
                parameterMap: function (options, operation) {
                    switch (operation) {
                        case "read":
                            return JSON.stringify(options);
                            break;
                        //case "destroy":
                        //    return JSON.stringify(options);
                        //    break;
                        //case "create":
                        //case "update":
                        //    return JSON.stringify(options);
                        //    break;
                    }
                }
            },
            schema: {
                model: {
                    id: "AgencySystemID", // the identifier of the model
                    fields: {
                        "AgencySystemID": { type: "number", editable: false },
                        "AgencyID": { type: "number", editable: false },
                        "Description": { type: "string" },
                        "DatabaseTypeID": { type: "number" },
                        "DataSource": { type: "string" },
                        "InitalCatalog": { type: "string" },
                        "UserID": { type: "string" },
                        "Password": { type: "string" },
                        "LastImportStartDateTime": { type: "date" },
                        "LastImportEndDateTime": { type: "date" },
                        "NextImportDateTime": { type: "date" },
                        "UpToDateTime": { type: "date" },
                        "ImportFrequency": { type: "number" },
                        "ImportFrequencyUnitID": { type: "number" },
                        "MaxImportWindow": { type: "number" },
                        "IsActive": { type: "boolean" }
                    }
                }
            }
        });
        ds.read({ Id: agencyId });
        
        ds.fetch();
        var datasourcedata = ds.data();
        
        for (var i = 0; i < datasourcedata.length; i++) {
            var dataitem = datasourcedata[i].Description;
            alert(dataitem);
        }



        return datasourcedata.length;
    };


Now here is the method from the controller the datasource is to call for the data.

        [HttpPost]
        public JsonResult GetAgencySystemInfo(long? agencyID)
        {
            var agencySystemInfo = (from p in dc.mst_AgencySystem where p.AgencyID == agencyID select p).ToList();

            return Json(agencySystemInfo, JsonRequestBehavior.AllowGet);

        }


Thanks,
rglunt68
Roy
Top achievements
Rank 1
 answered on 10 Feb 2014
1 answer
156 views
Hi,

I've posted a question to this topic a year ago and the solution went fine. Today I updated to the newest version of Kendo UI and now I have problems with the code. Looks like the update broke things for me.

The original question was, how to bind data in a clientdata from the parent row. The solution worked by using the DetailInit Method of the Parent Grid to set the data in the datasource of the Childgrid.
http://www.telerik.com/forums/grid-bind-a-clientdetailtemplate-to-a-collection-in-parent-row

My Parent Grid looks like this:
​
01.@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02..Name("commissionGrid")
03.        .Columns(
04.            col =>
05.            {
06.                    // cols..
07.            })
08.            .ClientDetailTemplateId("detailTemplate")
09.        .DataSource(dataSource => dataSource
10.       .Ajax()
11.       .ServerOperation(false)
12.    )
13.    .Events(events => events.DetailInit("initDetail"))
14.    .BindTo(Model.GroupedDetails)


Child Template:
01.@(Html.Kendo().Grid<Models.AgentCommissionDetail>()
02.        .Name("details_#=CustomerNr#")
03.        .Columns(col =>
04.        {
05.        // cols
06.        })
07.        .DataSource(dataSource => dataSource
08.            .Ajax()
09.            .ServerOperation(false)
10.           .Sort(p => { p.Add(x => x.ArticleGroup); p.Add(x => x.DiscountGroup); p.Add(x => x.ProductGroup); p.Add(x => x.Revenue).Descending(); })
11.        )
12.        .Pageable()
13.        .Sortable()
14.        .ToClientTemplate()
15.)

And finally the DetailInit to wire it together:
1.function initDetail(e) {
2.    var grid = $("#details_" + e.data.CustomerNr).data("kendoGrid");
3.    grid.dataSource.data(e.data.Details);
4.}

As I said, everything worked fine in the last years version. 

Following steps happen:
 - I expand a row
 - My data is shown as usual
 - But now, an post server request is made to my controller action. That's pretty strange, because I didn't specify any read methods in my datasource.
 - Since no data is returned from the controller, the grid will be empty as soon as the request is finished.

If I comment out the DataSource specification of the Childgrid, no request is made. But then my data is not sortedand Server Paging is enabled. Due to this, I tried to create a new datasource in the initDetail JS-Function, which has the specified sort-definition and turned off server paging. But I'm unable to set the Grid's datasource (already searched in the forums).

Was there a breaking change?

Thanks for any advices.

Greets


Petur Subev
Telerik team
 answered on 10 Feb 2014
1 answer
256 views
I am having trouble determining how to setup a TabStrip to load a tab's content from a json controller action and bind it to a kendo template; especially since @(Html.Kendo().DataSource()) and @(Html.Kendo().TabStrip().DataSource()) seem to be M.I.A.

Therefore, would it be possible to get an updated version of the ajax.cshtml demo on http://demos.telerik.com/kendo-ui/web/tabstrip/ajax.html that demonstrates how to obtain the json data and bind the data to a kendo template rather than having the data hard-coded within the ajaxContent1.html, ajaxContent2.html, and ajaxContent3.html files?
Alexander Popov
Telerik team
 answered on 10 Feb 2014
1 answer
661 views
I've been trying to figure out how to save and recover the column order as set by the user. Does anyone have any working example code on how they've managed to accomplish this? I've found examples of saving filter, sort and page info I've also figure out how to save column viability information but haven't found any information regarding saving user defined column order.

Any help would be appreciated.
Dimiter Madjarov
Telerik team
 answered on 10 Feb 2014
2 answers
215 views
Hello,

Can you give me a complete example for dropdownlist in the editortemplates?

For now I have to change all my dropdownlist in every views like this and I Wonder if it's possible to define a generic way in EditorTemplates?

​
@(Html.Kendo().DropDownList()
    .Name("NoRisque") // Name of the widget should be the same as the name of the property
    .DataValueField("Value") // The value of the dropdown is taken from the EmployeeID property
    .DataTextField("Text") // The text of the items is taken from the EmployeeName property
    .BindTo((SelectList)ViewBag.NoSource) // A list of all employees which is populated in the controller
)
Louis
Top achievements
Rank 1
Iron
Iron
Iron
 answered on 07 Feb 2014
4 answers
276 views
Hello,

I have a Visual Studio 2012 Telerik MVC 4 Web Application (Razor) Project and I cannot see the rad controls when I have a cshtml page selected. If I add in an aspx view I can see them for it. Can someone please let me know how to fix the toolbox so I can drag and drop rad controls onto my cshtml pages or if it is possible to do at all?
Dominick
Top achievements
Rank 1
 answered on 07 Feb 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?