Telerik Forums
UI for ASP.NET MVC Forum
4 answers
321 views
I have an ajax multiselect with autobind of false.  When returning to the page I would like my selected value(s) to display when the page loads, but they currently do not display until I click in the mulitselect.

Is there anything I can do to make this happen? 

I've attached a sample project.
@(Html.Kendo().MultiSelectFor(x => x.ReportOwner)
    .DataTextField("Name")
    .DataValueField("Pid")
    .DataSource(dataSource => dataSource
        .Read(read => read.Action("_RelatedEmployees", "AdvancedSearch"))
        .ServerFiltering(false)
        .Events(events => events.Error("onError"))
    )
    .AutoBind(false)
    .Placeholder("Select report owners...")
)
Georgi Krustev
Telerik team
 answered on 31 May 2013
13 answers
521 views
Here is our scenario:
We have a tree view control on the left with the list of document types and a grid control on the right that will list the documents (based on document type selection) with both inside a splitter control.When the users clicks on the document type, we want to recreate the grid because based on the document type the columns will change. 

For Example:
Document Type A will have columns Name, Type, Create Date, Attribute1, Attribute 2
Document Type B will have columns Name, Type, Create Date, Attribute6, Attribute 7, Attribute 8, Attribute 9
Document Type C will have columns Name, Type, Create Date, Attribute5

Problem:
When we click on the document type, the old column still exists and the new columns are not created but the data gets refreshed.

Questions:
1) What is the best option for our scenario?
2) Is there a way to destroy and recreate grid on demand?
3) If we have to destroy and recreate every time the users click on the document type, will that impact performance?

Here is  the code to create grid:
@model System.Data.DataTable

@(Html.Kendo().Grid(Model)
    .Name("DocumentGrid")
    .Columns(columns =>
    {
        foreach (System.Data.DataColumn column in Model.Columns)
        {
            columns.Bound(column.ColumnName).Groupable(column.ColumnName != "Id").Title(column.Caption).Hidden(column.ColumnName == "Id");
        }
    })
    .Pageable()
    .Sortable()
    .Navigatable()
    //.Scrollable()
    .Filterable()
    .Groupable()
    .ColumnMenu()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Model(model =>
            {
                foreach (System.Data.DataColumn column in Model.Columns)
                {
                    model.Field(column.ColumnName, column.DataType);
                }                
            })
        .Read(read => read.Action("GetDocuments", "Controller"))
        .PageSize(20)
    )
)

Here is the code the create the tree view:
@helper RenderTreeView()
{
    @(Html.Kendo()
          .TreeView()
          .ExpandAll(true)
          .Name("treeview")
          .DataTextField("Text")
          .Events(events => events
                                  .Select("onChange"))
          .BindTo(Model, mappings =>
          {
              mappings.For<Test.Models.AllDocumentType>(binding => binding
                                                                                     .ItemDataBound((item, AllDocumentType) =>
                                                                                     {
                                                                                         item.Id = AllDocumentType.Id;                                                     
                                                                                         item.Text = AllDocumentType.Text;                        
                                                                                     })
                                                                                     .Children(AllDocumentType => AllDocumentType.DocumentTypes));
              mappings.For<Test.Models.DocumentType>(binding => binding
                                                                                  .ItemDataBound((item, DocumentType) =>
                                                                                  {
                                                                                      item.Id = DocumentType.Id.ToString();
                                                                                      item.Text = DocumentType.Name;
                                                                                  }));
          })                     
    )
}

Here is the onchange event:
function onChange(e) {
        var data = treeview.dataItem(e.node);
        
        $.post('@Url.Action("DocumentGrid", "Collector")', {
            id: data.id
        }, function (data) {
            var grid = $("#DocumentGrid").data("kendoGrid");
            grid.dataSource.read();            
        });
    }; 

Thanks,
Atanas Korchev
Telerik team
 answered on 30 May 2013
9 answers
642 views
Im trying to use a time picker without any luck.

@if (Model.OrderEndTime.HasValue)
     {
         @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15).Value(Model.OrderEndTime.Value.ToString("HH:mm tt"))
     }
     else
     {
         @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15)
     }
My problem is the picker is not getting bound to the value. The value is returned, I have check by 

@Html.LabelFor(m => m.OrderEndTime)
       @if (Model.OrderEndTime.HasValue)
       {
           @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15).Value(Model.OrderEndTime.Value.ToString("HH:mm tt"))
           <span>@Model.OrderEndTime.Value.ToString("HH:mm tt")</span>
       }
       else
       {
           @Html.Kendo().TimePickerFor(m => m.OrderEndTime).Interval(15)
       }
adding the span and the value is correct. Do I need to do something else to get the time picker working?

Thank you!
Vladimir Iliev
Telerik team
 answered on 30 May 2013
1 answer
123 views
I have a kendo window and button in my asp.net mvc 3 application view.

on click of a button I am opening the above declared window using below javascript code.
var windowobj = window.data("kendoWindow");
           windowobj.open();
           windowobj.center();
hen in the window i enter value in the textbox. the opened window has Ok button, on click of that button, we use java-script code.
windowobj.close();
Now again clicking on parent button I open the window and expect that the text box in window will have no values. but it retains those values. Is there a function like refresh which will clear the previous contents.
Dimo
Telerik team
 answered on 30 May 2013
1 answer
90 views
Hello!
I use Tabstrip!
I have 2 items (Tabstrip_1 & Tabstrip_2)
inside Tabstrip_1: 
<div> with <div> and ....
inside Tabstrip_2:
<div> inside this div <div> with <img>
And I have <script> for zoom img

!!!!!!!
If I use SelectIndex(0), all bad and please see SelectIndex(0).png
If I use SelectIndex(1), all good and please see SelectIndex(1).png

Why this is occurs?
How I can use SelectIndex(0),so that get good img in second tabstrip item

+ I attached my project
http://www.sendspace.com/file/452c8a
Dimo
Telerik team
 answered on 30 May 2013
4 answers
542 views
Hi,

can anyone show me how to use a template for the labels in a chart legend in Kendo for MVC? The fluent api allows for controlling font, color, position, etc, but the labels template is nowhere to be found.

Below is a piece of code taken from the DataViz demo, to illustrate what I mean.

$("#chart").kendoChart({
                        theme: $(document).data("kendoSkin") || "default",
                        title: {
                            text: "Break-up of Spain Electricity Production for 2008"
                        },
                        legend: {
                            position: "bottom",
                            labels: {
                                template: "#= text # (#= value #%)"
                            }
                        },

Any help is greatly appreciated.

Regards,
Erwin
Hristo Germanov
Telerik team
 answered on 30 May 2013
1 answer
217 views
Hi

I'm generating the graph dynamically based on loaded description and data.
The (simplified) code as follows:
<div class="chart-wrapper">
    @(Html.Kendo().Chart()
        .Name("Chart1")
        .Transitions(false)
        .Title(d.graph_name)
        .Series(series => {
            foreach (www.Models.ChartDataItem s in d.chart_items)
            {
                if (s.type == "area") {
                    series.Area(s.name)
                    .Aggregate(ChartSeriesAggregate.Avg);
                }
                if (s.type == "line")
                {
                    series.Line(s.name)
                    .Aggregate(ChartSeriesAggregate.Avg);
                }
            }
        })
Is there a better (dynamic) way to set chart type without having the if/switch block?
Besides Aggregate I have a lot of options to set for most (but not all) series. So I wouldn't need to copy the lines for every possible chart type. Is it possible in current solution to catch each series (created by e.g. .Area()) in a variable and conditionally set properties on it?
Would the current approach to build a "very dynamic" chart in a View recommended? Is it possible build it completely in an Action instead?
Yes, the question might be related to razor/htmlhelpers in general, still interested in recommended Kendo approach. Thanks.
 Raido
Hristo Germanov
Telerik team
 answered on 30 May 2013
8 answers
800 views
Hi I have seen a similar post however I would like some clarification.
Desi: we have MVC.NET application which binds grid to model via Ajax binding.  When user submits the data and we refresh the page, we have a requirement to keep the user original selections (sorting, filtering, etc.).  You already posted that you do not support scenario like this "out of the box".  However I would like to know whether there is a way (some js method or control id or anything at all that would allow me to get to those selections before the page submitted via JavaScript.
Thanks.
Petur Subev
Telerik team
 answered on 30 May 2013
1 answer
300 views
Hi,

Kindly refer the below points and then suggest us to proceed further.

1. We have large database , our main criteria is to improve the performance of data binding in web.
2. As we have read about Kendo UI as client based, so we have doubts whether we can go for MVC Entity Framework with Kendo UI without using web service.

Thanks & Regards,
Vel.
Petur Subev
Telerik team
 answered on 29 May 2013
1 answer
173 views
Hi all.

Currently, I have the following code in my project:
@Html.TextBoxFor(model => model.CPF, new { alt = "cpf", style = "width: 150px;" })

Now, I would like to transform it in a Kendo control with a mask like that: "000.000.000-00". How can I do that with Kendo?

Thanks.
Atanas Korchev
Telerik team
 answered on 29 May 2013
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?