Telerik Forums
UI for ASP.NET MVC Forum
1 answer
115 views

Hi,

I have a custom class with a few strings and a list My grid is bound to a collection of my custom class and one of the columns is for the list.count. When the Grid renders, the column is empty. When reviewing the html code for the Grid, I discovered that the object type of list.count is now "object", see below:

{"Provider":{"type":"string"},"Type":{"type":"string"},"Bills":{"type":"object"}

 Where bills is a List<>. 

Alexander Popov
Telerik team
 answered on 17 Apr 2015
1 answer
261 views
Hi everyone,

I've created a  Grid Hierarchy here..I was able to get the column values from my Parent Grid(CustomerGrid) to use it on a ClientTemplate for example 

(@Html.ActionLink("Add Order", "AddOrder", "Customer", new { customerId = "#= CustomerId#" }, null).ToHtmlString()). 

But when I'm trying to adapt this kind of code, now getting the customerOrderId field from my Child Grid and use it on my ClientTemplate for example 

(@Html.ActionLink(AmsStrings.LabelEditAmendment, "EditOrder", "CustomerOrder", new { orderId = "#= OrderId#" }, null).ToHtmlString())

 I've retrieved nothing from here.The later code was used inside the Child Grid? What is wrong with my code? Why is it column values from my Parent Grid are available for use on my ClientTemplate while column values on my Child Grid are not available for use? 

 

@(Html.Kendo().Grid<customerviewmodel>
()
.Name("CustomerGrid")
.Columns(columns =>
{
columns.Bound(item => item.CustomerId).Hidden(true);
columns.Bound(item => item.Name);
columns.Template(t => { })
.Title("")
.Width(120)
.ClientTemplate("<div class='btn-group'>
    " +
    "<a class='btn btn-default btn-sm dropdown-toggle' data-toggle='dropdown'> Action <span class='caret'></span></a>" +
    "<ul class='dropdown-menu'>
        " +
        "
        <li>" + (@Html.ActionLink("Add Order", "AddOrder", "Customer", new { customerId = "#= CustomerId#" }, null).ToHtmlString()) + "</li>" +
        "
    </ul>
</div>");
 
})
.Selectable(selectable =>
{
selectable.Enabled(true);
selectable.Mode(GridSelectionMode.Single);
})
.ClientDetailTemplateId("template")
.DataSource(datasource => datasource.Ajax()
.Model(model =>
{
model.Id(m => m.CustomerId);
})
.Read(read => read.Action("CustomerDataSource", "Customer")))
.Sortable())
 
 
 
<script id="template" type="text/x-kendo-template">
    @(Html.Kendo().Grid
    <CustomerOrderViewModel>
        ()
        .Name("grid_#=CustomerId#")
        .Columns(columns =>
        {
        columns.Bound(item => item.OrderId).Hidden(true);
        columns.Bound(item => item.OrderName);
        columns.Template(@<text></text>)
        .Title("")
        .Width(100)
        .ClientTemplate("<div class='btn-group'>
            " +
            "<a class='btn btn-default btn-sm dropdown-toggle' data-toggle='dropdown'>Action<span class='caret'></span></a>" +
            "<ul class='dropdown-menu'>
                " +
                "
                <li>" + (@Html.ActionLink("Edit", "EditOrder", "CustomerOrder", new { orderId = "#= OrderId#" }, null).ToHtmlString()) + "</li>" +
                "
                <li>" + (@Html.ActionLink("View", "ViewOrder", "CustomerOrder", new { orderId = "#= OrderId#" }, null).ToHtmlString()) + "</li>" +
 
                "
            </ul>
        </div>");
 
        })
 
        .Editable(editable => editable.Enabled(false))
        .Sortable()
        .Selectable(selectable =>
        {
        selectable.Enabled(true);
        selectable.Mode(GridSelectionMode.Single);
        })
        .DataSource(datasource => datasource
        .Ajax()
        .ServerOperation(false)
        .PageSize(5)
        .Model(model => model.Id(p => p.OrderId))
        .Read(read => read.Action("CustomerOrderDataSource", "CustomerOrder", new { customerOrderId = "#=customerId#" })))
        .ToClientTemplate())
 
 
 
</script>
Nikolay Rusev
Telerik team
 answered on 17 Apr 2015
5 answers
399 views
Here is the scenario:I have an ASP.Net MVC 4 application, using Kenod grids and toolbars from Telerik UI for ASP.Net MVC. There is a main grid with a Client Detail template defined. The template contains a toolbar, and each tab opens a Kendo grid which takes the primary key from the parent grid. All of these grids are editable, all but one opening a template view. It is the "all but one" where I am having issues that I hope you can help with.Here is the code for this one grid. Instead of being Editable, it has a custom Toolbar defined with a button:items.Add().Text("Linked Files").Content(obj =>
         Html.Kendo().Grid<MedSouth.Models.LinkedFilesModel>()
        .Name("LinkedFilesGrid#=PkPacketID#")
        .Sortable()
        .Scrollable()
        .Filterable()
        .Columns(columns =>
        {
            columns.Command(command => { command.Edit(); command.Destroy(); }).Width(130);
            columns.Bound(e => e.PkLinkedFilesID).Width(130).Hidden(true);
            columns.Bound(e => e.FkPacketID).Width(130).Hidden(true);
            columns.Bound(e => e.FileName)
                .Width(100)
                .Title("Download File")
                .Sortable(false)
                .Filterable(false)
                //.ClientTemplate((@Html.ActionLink("Download File", "Download", "LinkedFiles", new { ID = "#=PkLinkedFilesID#" }, null).ToHtmlString()))
                ;
            columns.Bound(e => e.FileName).Width(130);
            columns.Bound(e => e.FileDescription).Width(175).Title("Description");
            //columns.Bound(e => e.FileURL).Width(300);
        })
        .ToolBar(tb =>
        {
            tb.Template(@<text>
                        <div >
                            <a class="k-button" href="\\#" onclick="return toolbar_click()">Add File</a>
                        </div>
                    </text>);
        })
        .DataSource(dataSource => dataSource
                .Ajax()
                .PageSize(5)
                .Model(model => model.Id(e => e.PkLinkedFilesID))
                    .Read(read => read.Action("LinkedFiles_Read", "LinkedFiles", new { FkPacketID = "#=PkPacketID#" }))
                    //    .Read(read => read.Action("LinkedFiles_Read", "LinkedFiles"))
                    .Update(update => update.Action("LinkedFiles_UpdateWithReplace", "LinkedFiles"))
                    .Destroy(destroy => destroy.Action("LinkedFiles_Destroy", "LinkedFiles"))
                    .Create(create => create.Action("LinkedFiles_Create", "LinkedFiles", new { PkPacketID = "#=PkPacketID#" }))
        )
        .ToClientTemplate()
);Here is the Javascript associated with the button. It opens an aspx page in containing a file upload control - <input name="files" id="files" type="file" runat="server" />. This allows the user to select a file and save information to the database. This data will then be displayed in the LinkedFiles grid defined above.<script type="text/javascript">    function toolbar_click() {
         console.log("Toolbar command is clicked!");
        ShowReport();
        return false;
    }    function ShowReport(e) {        var grid = $("#LinkedFilesGrid").data("kendoGrid");
        var dataItem = grid.dataItem($(e.currentTarget).closest("tr"));
        alert(e);        var id = dataItem.FkPacketID;
        var u = "/Test.aspx?ID=" + id;
        alert(u);
        kendoWindow = $("#window2").data("kendoWindow");
        kendoWindow.refresh({ url: u });
        kendoWindow.center();
        kendoWindow.open();
    }</script>In a test application, this all works fine, apart from having to hard-code the PkPacketID in the Javascript function, where the variable "id" is hard-coded.When the parent grid detail is opened, the grid sees the ID defined in the grid name - "LinkedFilesGrid#=PkPacketID#" correctly and attempts to populate the grid with matching records.Currently there are no records available to load into this grid, so step one is to click the "Add File" button, which needs to find and pass the PkPacketID to the aspx page.This is the first issue: I cannot find that ID. Tha Javascript in "ShowReport" errors with "Cannot read property 'dataItem' of null" - it is not seeing the grid containing the "Add File" button, whether the grid contains data or not.Question: How do I get the PkPacketID that is defined in the grid name?



Thanks for your help.
Stephen
Stephen
Top achievements
Rank 1
 answered on 16 Apr 2015
2 answers
126 views

I found out that defining "Editable(false)" for a model field doesn't seem to work when I've chosen GridEditMode.PopUp:

@(Html.Kendo().Grid<Pharmacy>()
    .Columns(columns => ...)
    .Editable(editable => editable.Mode(GridEditMode.PopUp))
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
        {
            model.Id(p => p.Id);
            model.Field(p => p.Id).Editable(false);
            model.Field(p => p.MyReadOnlyField).Editable(false);
        }))
)

In this case, the "Id" field and the "MyReadOnlyField" field will be shown in the popup as editable - which obviously is not the expected behavior.

Is this done intentional or is it a bug that Model definition doesn't work correctly with PopUp edit mode? Of course I can define a custom template, but that's not what I really want... from my view it's a bug or missing feature.

 

Thanks in advance,
Dimitrij

 

Dimitrij
Top achievements
Rank 1
 answered on 16 Apr 2015
1 answer
432 views

Does ASP.NET MVC scheduler support integration with google calender or outlook?

Thank you..

Vladimir Iliev
Telerik team
 answered on 16 Apr 2015
2 answers
103 views
Is there any property that will put the calendar button to the left of the input, or hide the button altogether so I can use Bootstrap's input-group feature?
Scott
Top achievements
Rank 1
 answered on 16 Apr 2015
1 answer
99 views

Hi,

I'm Thinking of moving from kendo ui html5 to the mvc version but I am worried about performance problem when moving to large scale (2,000,000 + users per month) 

Has anybody experienced issues with the MVC edition of kendo that might not happen in the Kendo UI html5 version? 

 

Thanks

Kiril Nikolov
Telerik team
 answered on 16 Apr 2015
3 answers
2.7K+ views

Hi

please i have create my grid and set bootstrap theme to it and add 3 custom button on it and every thing works fine but buttons not centered in each grid cell it's align to right (i have add rtl css) as you can see in attached image

 so please how can i set them center vertically and Horizontally in each grid cell ?

Ahmed
Top achievements
Rank 2
 answered on 16 Apr 2015
2 answers
146 views

my attempt (Where I have Kendo DropDownList 1 as #Type and Kendo DropDownList 2 as #Units:

            $('#Type').change(function (e) {
                //if (e.target.value == "Electirc") {
                var val = e.target.value;
                var ddL = $('#Units').data("kendoDropDownList")

                if (val == "Electric") {
                    ddl.dataSource.data({Text:"-", value:"null"},{Text:"kW", value:"kW"},{Text:"GJ", value:"GJ"})
                    //$("#Units").html("<option value='null'>item1:-</option><option value='kW'>item1: kW</option><option value='GJ'>item1: GJ</option>");
                } 
            })

The goal would be to have the contents of DDL2 to change based on the selection by DDL1

Kiril Nikolov
Telerik team
 answered on 16 Apr 2015
1 answer
351 views

I'm starting to build a Telerik UI for ASP.NET MVC project, just like the Grid Demo on http://demos.telerik.com/aspnet-mvc/

And i got this error when i debug project.

What problem?

Vladimir Iliev
Telerik team
 answered on 16 Apr 2015
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?