Telerik Forums
UI for ASP.NET MVC Forum
3 answers
577 views
Hi,

I have a Kendo MVC grid ajax binding. In one of the column I am displaying hyperlink using clientTemplate  , when user clicks on the hyperlink  it opens up another window with new controller action which is working fine too. But now the requirement  when user clicks on hyperlink check user session has not expired and user still authenticated and if it is so then open up that new window otherwise clicking on hyperlink should open login controller action.

 I have written a javascript function on onlcik event for <a> tag  which checks if user has authenticated then open up new window  else redirect to login page But its not working. when I run it I get the empty grid. Below is the code.
 
@(Html.Kendo().Grid<Anthology.Services.Interfaces.DTO.Web.Models.DocumentHistoryModel>()
                          .Name("Grid")
                          .EnableCustomBinding(true)
                          .BindTo(Model)
                          .Columns(columns =>
                          {
                              columns.Bound(c => c.DocumentType).Title("Document Type").Filterable(false).ClientTemplate("<a onclick=\"IsUserAuthenticated('" + "#= DocumentGuid #')\" " + " href='javascript:void(0)'>#= DocumentType#</a>");
                              columns.Bound(c => c.Action).Filterable(false);
                              columns.Bound(c => c.DocumentThumbnail).Title("Document Thumbmail").Sortable(false).Filterable(false).ClientTemplate("<text><img src='" + Url.Content("~/content/images/BDC4B60F-1EEC-4FE8-BB9C-2CA9F2F29664.png") + "' height='35' width='30' onmouseover='MagnifyImage()'/></text>");
                          })
                         .DataSource(dataSource => dataSource.Ajax()
                              .Read(read => read.Action("Index_Read", "Home"))
                              .PageSize(5)
                              .ServerOperation(true)
                          )
                          .Events(events => events.DataBound("onGridDataBound"))
                          )  

  function IsUserAuthenticated(documentguid) {
        var userAuthenticated= @User.Identity.IsAuthenticated.ToString().ToLower();
        if (userAuthenticated==true) {
            var url = @Url.Action("Index", "ImageViewer") + "/" + documentguid;
            $(".k-grid-content table tbody tr td text img").href = url;
            $(".k-grid-content table tbody tr td text img").target = '_blank';
        } else {
            var urlAd= @Url.Action("Index", "Admin");
            $(".k-grid-content table tbody tr td text img").href = urlAd;}

    }







Petur Subev
Telerik team
 answered on 27 Mar 2014
3 answers
582 views
I'm having a problem using the wizard to convert an existing project to a Telerik UI for Asp.Net MVC project. It will go through the conversion just fine and add all of the necessary resources, however after converting then I'm no longer able to use scaffolding to create new controllers based on defined data models. I get the error stating:

There was an error running the selected code generator: 'There was an error getting type 'ProjectName.Models.ModelName'. Try rebuilding the project.'

I've tried creating new models and then generating a new controller as well as creating a new controller based on previously defined models and get the same error in both instances. Simply rebuilding the project doesn't work. I even tried creating a new project, copying over my resources and converting it through the wizard again and get the same results. The target framework is 4.5.
Vesko
Telerik team
 answered on 27 Mar 2014
1 answer
384 views
I'm passing an IEnumerable collection into a foreach loop to create multiple series in a chart. I can verify that the foreach loop is indeed populating and creating the individual series. Though when the screen renders the space is there and I can inspect the element but it doesn't display on the screen. 

<table style="height: 400px; width:900px;">
            <tr>
                <td class="chart-wrapper">
                    @(Html.Kendo().Chart(Model)
                    .Name("LocationsChart")
                    .Title("Locations")
                    .Legend(legend => legend
                        .Visible(true)
                    )
                    .ChartArea(chartArea => chartArea
                        .Background("transparent")
                        .Width(900)
                        .Height(400)
                    )
                    .Series(series =>
                    {
                        foreach (var item in Model)
                        {
                            series.Column(new decimal[] { item.FuelSales, item.FuelSalesLyr, item.FuelSalesLy2 }).Name(item.LocUsageDesc);
                        }
                    })
                    .CategoryAxis(axis => axis
                        .Categories(new string[] {"Sales Yr to Date", "Sales Last Yr", "Sales 2yr"} )
                        .MajorGridLines(lines => lines.Visible(false))
                    )
                    .ValueAxis(axis => axis
                        .Numeric()
                        .Labels(labels => labels.Format("c"))
                        .Line(line => line.Visible(false))
                        .MajorGridLines(lines => lines.Visible(true))
                    )
                    .Tooltip(tooltip => tooltip
                        .Visible(true)
                        .Format("{0:C}")
                        .Background("grey"))
                    )
                </td>
            </tr>
        </table>

inspecting the element in the browser

jQuery(
function(){jQuery("#LocationsChart").kendoChart({"chartArea":{"background":"transparent","height":400,"width":900},"title":{"text":"Locations"},"legend":{"visible":true},"series":[{"name":"Home","type":"column","data":[368.59,1532.70,622.57]},{"name":"Shop","type":"column","data":[485.46,1824.32,856.80]},{"name":"Cdry","type":"column","data":[287.98,100.00,0]},{"name":"Cndo","type":"column","data":[363.69,872.09,0]},{"name":"Home","type":"column","data":[199.59,389.70,0]}],"categoryAxis":[{"majorGridLines":{"visible":false},"categories":["Sales Yr to Date","Sales Last Yr","Sales 2yr"]}],"valueAxis":[{"labels":{"format":"c"},"majorGridLines":{"visible":true},"line":{"visible":false}}],"tooltip":{"background":"grey","format":"{0:C}","visible":true}});});
Bob
Top achievements
Rank 1
 answered on 26 Mar 2014
1 answer
227 views
Has anyone experienced seeing "NaN/NaN/0NaN" in Kendo UI grids for fields prior to 1970?  I'm experiencing this in the Kendo UI grids, but not the previous Telerik UI grids. 
The fields (date of births) are of type "Datetime?"
The view i'm using uses .Format("{0:d}") for formatting, might that be the issue?
 
    columns.Bound(od => od.PatientDOB).Format("{0:d}").Title("PatientDOB").Width(50);

Attached 2 screenshots for visual representation.
I'm wondering if there is a workaround to this issue.

Any help is greatly appreciated.
Thanks!
Drew
Top achievements
Rank 1
 answered on 26 Mar 2014
7 answers
1.6K+ views
Hi guys,

I'm trying to embed a dropdown menu (bootstrap) inside a grid on the first column of each bound row (basically creating a menu for each item). It works but the menu is hidden behind the next row down so there's something to do with the markup of the grid overlapping the markup of the menu.

Here's the markup:

@(Html.Kendo().Grid<Listing>()
        .Name("grid")
        .DataSource(dataSource => dataSource
            .Ajax()
            .Read(read => read.Action("RefreshTable", "HomeController"))
        )
        .Columns(columns =>
        {
            columns.Bound(x => x.Number)
                .Width(120)
                .Template(@<text></text>)
                .ClientTemplate(
                    "<div class='btn-group'>" +
                    "<button type='button' class='btn btn-default btn-sm dropdown-toggle' data-toggle='dropdown'><span id='selectedTagType'>#= Number#</span> <span class='caret'></span></button>" +
                    "<ul class='dropdown-menu' role='menu'>" +
                    "<li><a onclick='editRecord();'></a>Edit</li>" +
                    "<li><a onclick='activateRecord();'></a>Activate</li>" +
                    "<li><a onclick='transferRecord();'></a>Transfer</li>" +
                    "</ul>" +
                    "</div>"
                );
            columns.Bound(x => x.TypeDescription);
            columns.Bound(x => x.PhoneNumber);
        })
    )
Bil
Top achievements
Rank 1
 answered on 26 Mar 2014
2 answers
168 views
Hello Telerik Team,

While in grid editing mode, is there a way to validate that a DateTime field is not in the past? or be within a specific range?

Thanks!
Alaa Masoud
Top achievements
Rank 1
 answered on 26 Mar 2014
7 answers
612 views
Hello,

I have some trouble to get the data bind of a list in a EditorTemplate for the schelduler.

Here is how i create the schelduler :
@(Html.Kendo().Scheduler<iMail.Web.Models.TaskViewModel>()
    .Name("scheduler")
    .Date(DateTime.Now)
    .StartTime(new DateTime(2013, 6, 13, 7, 00, 00))
    .Height(600)
    .Views(views =>
    {
        views.DayView();
        views.WeekView();
        views.MonthView();
        views.AgendaView(agenda => agenda.Selected(true));
    })
    .Selectable(true)
    .Timezone("Etc/UTC")
    .Events(e => e.Edit("onEdit"))
    .Editable(editable => {
        editable.TemplateName("_EditorTemplatePartial");
        editable.Resize(true);
    })
    .DataSource(d => d
            .Model(m => {   
                m.Id(f => f.TaskID);
                m.Field(f => f.Title).DefaultValue("No title");
                m.RecurrenceId(f => f.RecurrenceID);
                m.Field(e => e.Attendees).DefaultValue(new List<iMail.Web.Models.CalendarAttendeeModel>());
            })
        .Events(e => e.Error("error_handler"))
        .Read("TasksRead", "Dashboard")
        .Create("TasksCreate", "Dashboard")
        .Destroy("TasksDestroy", "Dashboard")
        .Update("TasksUpdate", "Dashboard")
    )
)

Code of _EditorTemplatePartial.cs

<div data-container-for="Attendees" class="k-edit-field">
    @(Html.Kendo().MultiSelectFor(model => model.Attendees)
        .Name("myMultiSelectiHATEYOU")
        .HtmlAttributes(new { data_bind = "value:Attendees" })
         
        .DataTextField("AttendeeName")
        .DataValueField("ID")
        
        .BindTo(ViewBag.Contacts)
        .Value(Model.Attendees)
</div>

Here is the data load in the MultiSelect

ICollection<CalendarAttendeeModel> contacts = new List<CalendarAttendeeModel>();
 
                CalendarAttendeeModel att7 = new CalendarAttendeeModel();
                att7.AttendeeName = "Georgette";
                att7.ID = 4;
                att7.Email = "myemail@attendee7.com";
........
                contacts.Add(att7);
                contacts.Add(att8);
                contacts.Add(att9);
                contacts.Add(att10);
                ViewBag.Contacts = contacts;

The data in the multislect seems to be correctly loaded but when i want to save the data inside of  TasksCreate() i have some trouble with my list.
Sample : If i select 4 item, my list count 4 row but haven't any data inside.
Moreover i can't try to use a datasource because of this template ".Editable(editable => {        editable.TemplateName("_EditorTemplatePartial");"

public ActionResult TasksCreate([Kendo.Mvc.UI.DataSourceRequest]Kendo.Mvc.UI.DataSourceRequest request, TaskViewModel task)
 {
 
}

My CalendarAttendeeModel is a List inside of the model TaskViewModel

public class TaskViewModel : Kendo.Mvc.UI.ISchedulerEvent
    {
....
        public string Title { get; set; }
        public string Description { get; set; }
        public string StartTimezone { get; set; }
        public string EndTimezone { get; set; }
....
        public List<CalendarAttendeeModel> Attendees { get; set; }
}


I can't get the selected data in the list inside of the editor template.
In the TasksCreate i can get the data of Description,... (it's the user who write the data) but for the List, i have a big problem.


I use Kendo UI 2013.3.1511 and Razor engine.

I'm stuck with that :/
Any idea to suceed ?
Shimon
Top achievements
Rank 2
 answered on 26 Mar 2014
7 answers
699 views
Hello -

I have the following TreeView in my application:

@(Html.Kendo().TreeView()
                            .Name("treeview")
                            .ExpandAll(true)
                            .Events(events => events.Select("onTreeNodeSelected"))                                                          
                            .BindTo((IEnumerable<TreeViewItemModel>)ViewBag.NavigationTree))

I have a button on the page that when clicked a KendoWindow gets displayed and allows the user to enter in text for a new node.  On the submit button within the KendoWindow it posts the AJAX form and the ViewBag.NavigationTree gets updated.

How can I have the new node be added to the tree via AJAX?  Essentially I want to update the TreeView's BindTo when the ViewBag.NavigationTree gets updated via an AJAX call.

Thanks in advance,
Dan

Alexander Popov
Telerik team
 answered on 26 Mar 2014
5 answers
839 views
Hi,

I'm trying to redirect to a controller action and pass the ID of the selected tree node into the controller action.

Ideally, I would like to use some code like this:

<div class="kendo-tree">
    @(Html.Kendo().TreeView()
        .Name("treeview")
        .DataTextField("Name")
        .TemplateId("treeview-template")
        .DataSource(dataSource => dataSource
            .Read(read => read.Action("DashboardTree", "Home"))
         )
        .Events(e => e.Select("onSelect"))
    )
</div>
And here's what the onSelect would do:
function onSelect(e) {
    var data = $('#treeview').data('kendoTreeView').dataItem(e.node);
     
    //alert("node clicked" + data.id);
    window.location  = @Url.Action("Edit", "Employee", new { id = data.id });
         
}
I'm not sure if window.location is the way to do this and would welcome better suggestions.  I don't have a form to submit, I just want to go to another page when the user clicks a tree node.  Surely I'm missing something here...

Thanks,
bh
Dimo
Telerik team
 answered on 26 Mar 2014
1 answer
392 views
I have a Kendo button with the click event defined as:

@(Html.Kendo().Button()
                    .Name("btnAddNewLineItem")
                    .Tag("span")
                    .Icon("plus")
                    .Content(@InvSubModule.Infrastructure.Localization.ResourceManager.GetString("AddNew") +"   " + "<span></span>")
                    .HtmlAttributes( new {type = "button"} )
                    .Events(ev => ev.Click("AddLineItemButtonRequest"))                 
                )   

In my JavaScript method: "AddLineItemButtonRequest", the last line sets the focus to another control on the page via jQuery:

$("#LineItemType").focus();

However, after this line, the focus is shifted back to the Kendo button above. Is there another way I should be setting the focus?

Thanks for your time,
Scott Dulock


Dimiter Madjarov
Telerik team
 answered on 26 Mar 2014
Narrow your results
Selected tags
Tags
Grid
General Discussions
Scheduler
DropDownList
Chart
Editor
TreeView
DatePicker
ComboBox
Upload
MultiSelect
ListView
Window
TabStrip
Menu
Installer and VS Extensions
Spreadsheet
AutoComplete
TreeList
Gantt
PanelBar
NumericTextBox
Filter
ToolTip
Map
Diagram
Button
PivotGrid
Form
ListBox
Splitter
Application
FileManager
Sortable
Calendar
View
MaskedTextBox
PDFViewer
TextBox
Toolbar
MultiColumnComboBox
Dialog
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Wizard
Security
Styling
Chat
DateInput
MediaPlayer
TileLayout
Drawer
SplitView
Template
Barcode
ButtonGroup (Mobile)
Drawer (Mobile)
ImageEditor
RadioGroup
Sparkline
Stepper
TabStrip (Mobile)
GridLayout
Badge
LinearGauge
ModalView
ResponsivePanel
TextArea
Breadcrumb
ExpansionPanel
Licensing
Rating
ScrollView
ButtonGroup
CheckBoxGroup
NavBar
ProgressBar
QRCode
RadioButton
Scroller
Timeline
TreeMap
TaskBoard
OrgChart
Captcha
ActionSheet
Signature
DateTimePicker
AppBar
BottomNavigation
Card
FloatingActionButton
Localization
MultiViewCalendar
PopOver (Mobile)
Ripple
ScrollView (Mobile)
Switch (Mobile)
PivotGridV2
FlatColorPicker
ColorPalette
DropDownButton
AIPrompt
PropertyGrid
ActionSheet (Mobile)
BulletGraph
Button (Mobile)
Collapsible
Loader
CircularGauge
SkeletonContainer
Popover
HeatMap
Avatar
ColorGradient
CircularProgressBar
SplitButton
StackLayout
TimeDurationPicker
Chip
ChipList
DockManager
ToggleButton
Sankey
OTPInput
ChartWizard
SpeechToTextButton
InlineAIPrompt
TimePicker
StockChart
RadialGauge
ContextMenu
ArcGauge
AICodingAssistant
+? more
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?