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

I have a grid where each row has a custom command that opens a details modal. The details modal is populated with the contents of a kendo template. I want to include a kendo grid inside of that template.

Data structure is Contract (main page)->CoveredEquipment (first grid)->WearableParts (grid on modal)

My problem is that I get a javascript "invalid template" error when the page is loaded. It seems to not like

#= kendo.render(kendo.template($("\#wearablePartsGridTemplate").html()), WearableParts); #

 in the modal template.

 

What am I doing wrong?

 

<script id="wearablePartsGridTemplate" type="x-kendo-template">
 
    @(Html.Kendo().Grid<FieldServiceWeb.Areas.Admin.Models.ServiceContract.WearablePartViewModel>()   
    .Name("wearablePartsGrid")
    .DataSource(dataSource =>
        dataSource.Ajax()
            .Model(model => model.Id(p => p.PartNumber))
            .ServerOperation(false)
            .Update("Update", "ServiceContracts", new { area = "Admin" })
        .Destroy("Delete", "ServiceContracts", new { area = "Admin" })
        .Create("Create", "ServiceContracts", new { area = "Admin" })
    )
    .Columns(columns => {
        columns.Bound(c => c.PartNumber).Title("Part");
        columns.Bound(c => c.Description);
        columns.Bound(c => c.IsActive).Title("Active");
        columns.Command(c => c.Destroy().Text("Delete"));
    })
    .ToClientTemplate())
 
</script>

<script type="text/x-kendo-template" id="wearablePartsContent">
        <label>Wearable parts for <strong>#: CSPId # - #: Description #</strong></label>
        #= kendo.render(kendo.template($("\\#wearablePartsGridTemplate").html()), WearableParts); #       
    </script>

<script>

function openWearableParts(e) {
            e.preventDefault();

            var dataItem = this.dataItem($(e.currentTarget).closest("tr"));

            $("#wearablePartsModal").find(".modal-body").html(wearablePartsTemplate(dataItem));

            //createGrid();

            $("#wearablePartsModal").modal("show");
        }

</script>

Daniel
Telerik team
 answered on 21 Apr 2015
6 answers
81 views

I have a Service Contract that can have many pieces of Covered Equipment. I would like to use the grid control to let users add and edit equipment BEFORE the parent object is created (basically storing it all client-side, and then sending it back with the parent info in one form POST).

Is this scenario possible? All of the examples I've found are using AJAX calls on each edit, which I can't do.

Scott
Top achievements
Rank 1
 answered on 21 Apr 2015
6 answers
805 views

I've got the following code which doesn't seem to render correctly, it moves the fields outside of the form, so the form is an empty tag. I tried adding .Render() to both tabstrip and window at different times and gained a .NET error

"CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments "

@(Html.Kendo().TabStrip()
          .Name("tabstrip")
          .Items(tabstrip =>
          {
 
@*More tabs*@
                 tabstrip.Add().Text("Create New Task")
                  .Content(
                @<text>
                    @using (Ajax.BeginForm(null, null, new AjaxOptions { Url = Url.Action("UserAddNewTask", "ProjectApi", new { area = "API" }), OnSuccess = "CloseAndRefreshTaskGrid()" }, new { @id = "newTaskForm" }))
                        {
                        @Html.Hidden("Id")
  
                        <div class="container-fluid">
                            @*More fields*@
  
                            <div class="row top10">
                                @Html.Label("Task Name", new { })
                                @Html.Kendo().TextBoxFor(model => model.Name)
                                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
                            </div>
  
                            <div class="row top10">
                                <button class="btn btn-success" id="btnNewTaskSubmit" type="submit">Submit</button>
                            </div>
                        </div>
                        }
  
                </text>);
          }))

@(Html.Kendo().TabStrip()
          .Name("tabstrip")
          .Items(tabstrip =>
          {
                 tabstrip.Add().Text("Create New Task")
                  .Content(
                @<text>
                    @using (Ajax.BeginForm(null, null, new AjaxOptions { Url = Url.Action("UserAddNewTask", "ProjectApi", new { area = "API" }), OnSuccess = "CloseAndRefreshTaskGrid()" }, new { @id = "newTaskForm" }))
                        {
                        @Html.Hidden("Id")
 
                        <div class="container-fluid">
                            @*More fields*@
 
                            <div class="row top10">
                                @Html.Label("Task Name", new { })
                                @Html.Kendo().TextBoxFor(model => model.Name)
                                @Html.ValidationMessageFor(model => model.Name, "", new { @class = "text-danger" })
                            </div>
 
                            <div class="row top10">
                                <button class="btn btn-success" id="btnNewTaskSubmit" type="submit">Submit</button>
                            </div>
                        </div>
                        }
 
                </text>);
          }))

​

@(Html.Kendo().Window()
    .Name("editTaskModal")
    .Modal(true)
    .Draggable()
    .Actions(a => a.Pin().Maximize().Minimize().Close())
    .Title("Edit Task")
    .Width(800)
    .Visible(false)
    .Position(p => p.Top(150))
    //.Content(@Partial/_TimesheetNewTask")
    .Content(@<text>@Html.Partial("Partial/_TimesheetNewTask")</text>)
)​

Daniel
Telerik team
 answered on 21 Apr 2015
3 answers
945 views
Hi,

In my project, I need to put some forms in kendo windows. These forms are in other partial view. I use this to load the partial view :

01.@(Html.Kendo().Window()
02.         .Name("editPasswordPopUp")
03.         .Visible(false)
04.        .Modal(true)
05.        .Width(600)
06.        .Height(500)
07.       .Position(settings =>
08.               settings.Top(70).Left(200))
09.         .Title("Edit your password")
10.         .Content("loading user info...")
11.        .LoadContentFrom("EditPassword", "Member")
12.         .Iframe(true)
13.         .Resizable()
14.         .Draggable()
15.         )

1.public ActionResult EditPassword() {
2.    return PartialView();
3.}

1.[HttpPost]
2.[ValidateAntiForgeryToken]
3.public ActionResult EditPassword(EditPasswordViewModel viewModel)
4.{
5.     [....]
6.     return RedirectToAction("Profile", "Member", new {id = viewModel.Id});
7.     [....]
8.}

And here is my PartialView :
01.@using Devoteam.CustomerPortal.Application.Helpers
02.@model Devoteam.CustomerPortal.ViewModels.EditPasswordViewModel
03.@{
04.    ViewBag.Title = "Edit";
05.    Layout = null;
06.}
07. 
08.@Styles.Render("~/Content/css")
09.@Scripts.Render("~/bundles/jquery")
10.@Scripts.Render("~/bundles/jqueryval")
11.@Scripts.Render("~/bundles/kendo")
12. 
13.@using (Html.BeginForm())
14.{
15.    @Html.AntiForgeryToken()
16. 
17.    <div id="messageError">
18.        @Html.ValidationSummary()
19.    </div>
20.  [...] // Fields
21.     
22.    <div class="buttons">
23.        <input type="submit" value="Confirm" class="big-button" />
24.        <input type="submit" value="Cancel" class="big-button" />
25.    </div>
26.}


When I click on the button to open the kendo window, the partial view load correctly in it.
When I submit my form, the action is correctly called. Here is my problem : when the controller has done his job, I call a RedirectToAction to redirect the user. But the page is loaded in the kendo window instead of the main window. Is there any solution to close the kendo window ?

Second question : how to close the kendo window when pressing the cancel button.


Thank you.
Alexander Popov
Telerik team
 answered on 21 Apr 2015
3 answers
300 views
Hi, I trying to add a custom delete command on the toolbar and I need to get the selected row and data. I'm using Server binding and I tried using some of the answers in the forum but it still didn't work.

function deleteCommand(e) {
    var grid = $('#reimbursementsGrid').data('kendoGrid');
    var rows = grid.select();
    rows.each(
        function () {
            var record = $(this).data();
            alert('Selected : ' + record.Id);
 
        }
    )
}
The alert is always showing undefined. Can someone please point me in the right direction please?

The Id is defined in the model and is a hidden column
@(Html.Kendo().Grid(Model)
        .Name("reimbursementsGrid")
        .DataSource(dataSource => dataSource
            .Server()
            .Model(model =>
            {
                model.Id(r => r.Id);

...
        .Columns(columns =>
        {
            columns.Bound(o => o.Id).Hidden(true);
...
Stu
Top achievements
Rank 1
 answered on 20 Apr 2015
2 answers
63 views

Picture of the chart: http://i.imgur.com/K88FEJd.png

 

I cannot get the chart to do categories correctly. If you look at the dates in the following data they are all different except if it is a different department. But in the picture they seem to merge for some reason. Can someone explain this?

Here is my return JSON data...

[{"DepartmentName":"Information Technology","TicketDate":"2015-04-01","TicketCt":3},{"DepartmentName":"Information Technology","TicketDate":"2015-04-16","TicketCt":1},{"DepartmentName":"Human Resources","TicketDate":"2015-04-14","TicketCt":1},{"DepartmentName":"Human Resources","TicketDate":"2015-04-15","TicketCt":1}]

 Here is my code:

@(Html.Kendo().Chart<Guardian.ViewModels.TicketCount>()
                          .Name("LastTwoWeeks_Tickets")
                          .Title("Ticket Count In The Past 30 Days")
                          .Legend(legend => legend
                              .Position(ChartLegendPosition.Top)
                          )
                          .DataSource(ds => ds.Read(read => read
                              .Action("_NewTicketCtOverTwoWeeks_Read", "Home"))
                              .Group(group => group.Add(model => model.DepartmentName))
                              .Sort(sort => sort.Add(model => model.TicketDate).Ascending())
                          )
                          .Series(series => series.Line(model => model.TicketCt).Name("#= group.value #"))
                          .CategoryAxis(axis => axis
                              .Categories(model => model.TicketDate)
                          )
                          .ValueAxis(axis => axis.Numeric()
                              .Labels(labels => labels.Format("{0:N0}"))
                          )
                          .Tooltip(tooltip => tooltip
                              .Visible(true)
                              .Shared(true)
                              .Format("{0:N0}")
                          )
                    )

 

 

Joshua
Top achievements
Rank 2
 answered on 20 Apr 2015
2 answers
98 views
Greetings.

I had some sort of problems trying to attach my tests so I upload them to wetransfer so you can download them.
On the following link, you will find 2 projects: a WPF and MVC one.   http://bit.ly/1zigHWP


The point is to load and export documents between WPF RadRichTextBoxRichText and MVC Editor.
This is what simulate our enterprise softwares.

 

In the WPF test app, we have a file test.txt with a hexadecimal code of a document created in our WPF application's RadRichTextBoxRichText. 
If you click on the button "Import" you can see the original formatations. Then, if you click the button "Export" you will convert that doc to hexadecimal and copy it to the clipboard so you can past on the MVC test app.

 

In the MVC test app, you can past that hexadecimal code clicking on "Past Hex" button, and you will see that the document was imported well succeded with all formatations.

I guess the main problem begin in the WEB app. 

First problem:
If I export the document to hexadecimal from the MVC editor, clicking on " Get Hex" button, and copy that again using the button "Past Hex", you will realise that you lost all the spaces between lines.

Second problem:
To replicate the following problem, please, follow these steps:
1 - Click "Import From test.txt"
2 - Edit the line where it begins with  "No estudo efectuado não..." , delete the rest of that line leaving just that words, and apply a background color to them.
3 - Justify that words.
4 - Click "Get Hex" and copy the hex code written on the footer.
5 - Replace the hexadecimal code in test.txt in WPF application with the copied hexadecimal.
6 - Run the WPF app and click "Import"

Now, if you look, you can see that:
       The justified line is with extra spaces, 
       All the spaces between lines have been lost, 
       There is no background color on the justified line.

​

I apreciate the solution for these problems so that we can find a better way to import the documents in both technologies without any lost.
Regards.

Alexander Popov
Telerik team
 answered on 20 Apr 2015
1 answer
482 views

I have scoured the forums and following all of the instructions to try to get the DropDownlist to properly behave. What I am doing is using a wizard (in Jquery) form and each time the next button is called the following code is hit:

if (wizardForm.valid()) {// validate the form
   wizardForm.validate().focusInvalid();
.............}

The problem is when I change the ignore option to "", from ignore: ":hidden" the validation looks like it is successful and without validation errors however the next button does not advance to the next page. 

 

I have also tried the example from the "KendoInputs_Validation" project but that does not work at all in Visual Studio.

Vladimir Iliev
Telerik team
 answered on 20 Apr 2015
1 answer
153 views

Hi,



Is there a way to use Kendo().Menu() with complex
ItemDataBound ?

While creating simple menu with several menu option &
several children’s is ok, I did not managed to understand how to implement menu
item with several children & images & dropdown list & buttons.

In the attached image you will find the best explanation in
order to understand what I want I've attached an image

 

Thanks

Georgi Krustev
Telerik team
 answered on 20 Apr 2015
1 answer
1.1K+ views

Hello,

I have a grid with the filterMenuInit event set up to fire a custom function. However, the event is not firing when I open the filter menu. Here is some of the code for the grid:

 @(Html.Kendo().Grid(Model)
        .Name("Grid")
        .ColumnMenu()
        .Columns(columns =>
        {
            columns.Bound(m => m.Number)
                .Title("Number")
                .Width(140)
                .Filterable(ftb => ftb.Cell(cell => cell.ShowOperators(true).Template("NumberFilter")));
            columns.Bound(m => m.FirstName)
                .Title("First Name")
                .Width(140)
                .Filterable(ftb => ftb.Cell(cell => cell.Delay(@serverSideDelay).ShowOperators(true)));
            columns.Bound(m => m.LastName)
                .Title("Last Name")
                .Width(140)
                .Filterable(ftb => ftb.Cell(cell => cell.Delay(@serverSideDelay).ShowOperators(true));
        })
        .Pageable(pageable => pageable
                .Refresh(true)
                .ButtonCount(10))
        .ColumnMenu(menu =>
        {
            menu.Filterable(false);
            menu.Columns(false);
        })
        .Sortable(s => s
            .AllowUnsort(false)
            .SortMode(GridSortMode.SingleColumn))
        .Selectable()
        .EnableCustomBinding(true)
        .Events(e => e.FilterMenuInit("hideFilter"))
        .Filterable(ftb => ftb.Mode(GridFilterMode.Row))
        .DataSource(dataSource => dataSource
            .Ajax()
            .Model(model => model.Id(m => m.ID))
            .Sort(s =>
            {
                s.Add("LastName").Ascending();
            })
            .PageSize(10)
            .ServerOperation((bool)@ViewBag.IsServerSide)
            .Read(read => read.Action("ReadAction"))
            .Total((int)ViewBag.Count)
            .Events(events => events.Error("onKendoDataSourceError").RequestStart("checkFilter"))
        )
        .Events(e => e.Change("selectObject").DataBound("checkFilter"))
    )

 

I'm using version 2014.3.1316. Can you please help with this? Thanks.

Dimiter Madjarov
Telerik team
 answered on 17 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?