Telerik Forums
UI for ASP.NET MVC Forum
3 answers
331 views
I followed the sample code and when I load the application, all I get is a spinning circle in the dropdown list. 

I've tried several things, but can anyone find out what's wrong with the code I'm using to get the data in the dropdown list?

Razor Code:

@(Html.Kendo().DropDownListFor(model => model.EquipmentReturnStatusId)
        .Name("_EquipmentReturnStatusId")
        .DataTextField("EquipmentReturnStatusName")
        .DataValueField("EquipmentReturnStatusId")
        .DataSource(datasource => datasource.Read(read => read.Action("Read", "EquipmentReturnStatus")))
        .OptionLabel("Take me to your Leader")
 )

Controller Code:

[HttpPost]
public JsonResult Read()
{
    try
    {
        EquipmentReturnService.EquipmentReturnServiceClient client = new EquipmentReturnService.EquipmentReturnServiceClient();
        var returns = client.GetEquipmentReturnStatuses();
        return Json(returns);
    }
    catch (Exception ex)
    {
        string errorMessage = "An error occurred: " + ex.Message;
    }
    return null;
}

madladuk
Top achievements
Rank 2
 answered on 05 Dec 2012
1 answer
515 views
Hi,

I have a grid and bound data along with kendo upload control in the toolbar. i have written jquery as shown below to upload the files. but files are not being uploaded. none of the methods of upload control are firing. Also i need to restrict file types to upload. how to resolve this. Please help.



@(Html.Kendo().Grid<FileListRow>()
.Name("Grid")
.Selectable()
.Sortable()
    .ToolBar(tools => tools.Template("<div id='UploadArea' class='k-widget k-upload'> Upload a document : <span class='uploadFileType' >Please upload only Microsoft Office, Text, Email or PDF files.</span>" +
   "<div class='k-button k-upload-button' ><span>Select...</span><input id='uploadDocument' name='uploadDocument' type='file'  multiple='multiple' autocomplete='off' ></div>" +
         " <span id='spnValidDoc'>Forbidden file type.</span> <span id='spnValidFileSize'>Upload Failed! You can upload maximum of " + Model.DocumentExplorerMaxUploadSize + " MB</span>" +
   "</div>"))


.Columns(columns =>
{
    columns.Bound(file => file.flFileId).Hidden();
    columns.Bound(file => file.fdFolderId).Hidden();
    columns.Bound(file => file.flFileName).Title("File Name");//.ClientTemplate("<img src='#=FileIconUrl#' />  <span title='#=flFileDesc#'>#=flFileName#</span>").Title("File Name").Width(Model.IsAdministrator ? 300 : 800);
    columns.Bound(file => file.flFileDesc).Title("Description").Hidden();
    columns.Bound(file => file.flFileType).Title("Type").HtmlAttributes(new { style = "text-align:right" }).HeaderHtmlAttributes(new { style = "text-align:right", @width = "3%" }).ClientTemplate("<span style='text-transform: uppercase'>#= flFileType #</span>");
    columns.Bound(file => file.FileSize).Title("Size").HtmlAttributes(new { style = "text-align:right"}).HeaderHtmlAttributes(new { style = "text-align:right" });
    columns.Bound(file => file.flUpdateTime).Format("{0:MM/dd/yyyy hh:mm:ss tt}").Title("Date Uploaded").HtmlAttributes(new { style = "text-align:right", @width = "23%"  }).HeaderHtmlAttributes(new { style = "text-align:right" });
    columns.Bound(file => file.flUpdateTime).Format("{0:MM/dd/yyyy hh:mm:ss tt}").Title("Date Uploaded").HtmlAttributes(new { style = "text-align:right", @width = "23%" }).HeaderHtmlAttributes(new { style = "text-align:right" });
    columns.Bound(file => file.fdDownloadCount).Hidden();

   // columns.Bound(file => file.fdDownloadCount).ClientTemplate("<a href='" + Url.Action("Download", "Home") + "/#=flFileId#'>Download</a>");
    columns.Command(commands =>
    {
       // commands.Custom("Download").Action("Download", "Home", new { area = "Document" }).HtmlAttributes(new { onclick = "RefreshGrid(event, this)", Title = "Download" });
        commands.Edit().HtmlAttributes(new { Title = "Edit" });
        commands.Destroy().HtmlAttributes(new { Title = "Delete" });
       // commands.Custom("DownloadCount").Text("").Action("Download", "Home", new { area = "Document" }).HtmlAttributes(new { onclick = "ShowLog(event, this)", Title = "", id = "btnDownloadCount"});
    }).Width(Model.IsAdministrator ? 150 : 45).HtmlAttributes(new { @class = "t-gridButtonAlignment" });    
}).Events(events => events
            .DataBound("onRowDataBound")
            .Edit("onEdit"))
            .DataSource(dataSource => dataSource.Ajax().ServerOperation(false)
                                .Read("GetFileList", "Explorer", new { area = "Document", id = Model.SelectedFolderId })
                                .Model(model => model.Id(file => file.flFileId))
                                .PageSize(Model.DocumentExplorerPageSize)
                        .Update("Update", "Explorer", new { area = "Document" })
                        .Destroy("Delete", "Explorer", new { area = "Document", folderId = Model.SelectedFolderId })
                        ).Pageable(pager =>
                                    pager.PageSizes(true)
                                  ).Sortable()
                                                .Editable(editable => editable.Mode(Kendo.Mvc.UI.GridEditMode.PopUp).TemplateName("_EditFilePopup"))

        )

my jquery is -

$(document).ready(function () {
      ('#uploadDocument').kendoUpload
      
        ({
            async:
        { saveUrl: '@Url.Action("Upload", "Explorer")',  // $.Site.RelativeWebRoot + "Document/Explorer/Upload", "autoUpload": true },
            autoUpload: true,
            Upload: onUpload,
            Success: onUploadSuccess,
            Error: onUploadError
        }
        });

Petur Subev
Telerik team
 answered on 05 Dec 2012
1 answer
271 views
Hi,
I have the following dropdown lists declared in my view:

                <p>
                    <label for="ApplicationName">Application:</label>
                    @(Html.Kendo().DropDownList().Name("ApplicationNames")
                                                .BindTo(new SelectList(ViewBag.Applications)))
                </p>
                <p>
                    <label for="Roles">Roles:</label>
                    @(Html.Kendo().DropDownList().Name("Roles")
                                                   .DataSource(source =>
                                                   {
                                                       source.Read(read =>
                                                       {
                                                           read.Action("GetRoles", "Membership")
                                                                 .Data("filterRoles").Type(HttpVerbs.Post) ;
                                                       })
                                                       .ServerFiltering(true);
                                                   })
                                                       .Enable(false)
                                                      .AutoBind(false)
                                                      .CascadeFrom("ApplicationNames"))
                                                <script>
                                                    function filterRoles() {
                                                        return {
                                                            ApplicationNames: $("#ApplicationNames").val()
                                                        };
                                                    }
                                                </script>
                </p>


and my controller action :

    public class MembershipController : Controller
    {
        MembershipModel model = new MembershipModel();

        [HttpPost]
        public JsonResult GetRoles(string ApplicationNames)
        {
            List<String> roles = model.GetRolesForApplication(ApplicationNames);
           return Json(roles);
        }

but my GetRoles action never fires. Any ideas ?
Georgi Krustev
Telerik team
 answered on 05 Dec 2012
2 answers
624 views
I have a custom command button in a Client template that I want to fire a specific action.  I only want to fire the action. I do not want to redirect/render another View.  This is being done inside of a grid hierarchy.  Also, the action needs access to my model. Code for the template is below

<script id="myTemplate" type="text/kendo-tmpl">
<%: Html.Kendo().Grid<MyModel>()
     .Name("ThisGrid")
     .Columns(columns =>
     {
        columns.Bound(n => n.value)
                      .Title("Col1")
                      .Width(100);
        columns.Bound(n => n.IsEnabled)
                      .Width(100)
                      .ClientTemplate(
                          "# if (IsEnabled) { #" +
                               "Yes" + "#} else {#" +
                               "No" + "#}#");
        columns.Command(command => command.Custom(
                 "# if(IsEnabled) { #" +
                      "Disable" +
                      "#} else { #" +
                      "Enable" +
                      "#}#").Click("updateModel")).Width(40);
     })
     .DataSource(dataSource => dataSource
              .Ajax()
              .Read(read => read.Action(
                       "Binding_Model", "MyController")))
             .Pageable()
             .Sortable()
             .ToClientTemplate()
%>
Shannon
Top achievements
Rank 1
 answered on 04 Dec 2012
3 answers
423 views
Hi there, 

I am currently editing my grid not using the Kendo editor. I send the grid cell to my editor and refresh the grid after edition is complete. 
What I am trying to do is to keep the edited line highlighted using dataBound(). But because of the asynchronous load of data, the dataBound function is executed before my grid is fully loaded. 

Here is the used code, I really cannot figure out why the dataBound function is executed before data are loaded. 

var kendoDefaultParams = {
     // removed for clarity
    dataBound: onDataBound,
     // removed for clarity
};
 
$("#grid").kendoGrid(kendoDefaultParams);
 
function onDataBound() {
    gva.reSelectElements();
};
 
 
reSelectElements = function () {
    // gva.selectedVms() contains the previous selected elements
    if (gva.selectedVms().length == 0 || gva.selectedVms() == null || gva.selectedVms() == undefined) { return; }
    var id = gva.selectedVms()[0].uid;
    var grid = $("#grid").data("kendoGrid");
    var row = grid.table.find("tr[data-uid=\"" + id + "\"]");
    grid.select(row);
};

Am I doing something wrong ?? 
Daniel
Telerik team
 answered on 03 Dec 2012
1 answer
818 views
Hi,

We are facing an issue with assignment of content of the kendo window from a javascript. The content to be assigned is a url, which links to an action in a controller and this action method returns a partial view, which is to be shown in the window.

We are opening the window ,while clicking on the toolbar create button on the grid. Gird binding is given as follows and after that the declaration of the window is also given

@(Html.Kendo().Grid(Model.Posts)
                    .Name("Grid").Selectable()
                        .ToolBar(toolbar => toolbar.Template(
                            @<text>
                                <a class="k-button k-button-icon k-grid-add" href="#" onclick="AddNewPost(@Model.ClientId)" title="Add New Post">
                                <span class="k-icon k-add"></span>
                                </a>
                            </text>))

                                                .Columns(columns =>
                                                {
                                                    columns.Bound(p => p.poPostId).Hidden();
                                                    columns.Bound(p => p.poTitle).Title("Post Title").Width(390);
                                                    columns.Bound(p => p.poCreateTime).Format("{0:MM/dd/yyyy hh:mm:ss tt}").Title("Created").Width(180);
                                                    columns.Bound(p => p.poUpdateTime).Format("{0:MM/dd/yyyy hh:mm:ss tt}").Title("Last Updated").Width(200);
                                                    
                                                })
                                                .Pageable(pager => pager.PageSizes(true))
                                                .DataSource(dataSource => dataSource.Ajax()
                                                                                    .ServerOperation(false)
                                                                                    .Read(read => read.Action("GetMessages", "Home", new { area = "Post", id = Model.ClientId }))
                                                                                    .Model(model => model.Id(p => p.poPostId))
                                                                                    .PageSize(20)
                                                ).Sortable()
                                                            )    
                   
                        <script type="text/x-kendo-template" id="toobarTemplate">
                       
                        </script>    
                      

                    @(Html.Kendo().Window()
                            .Name("window")
                            //.Buttons(buttons => buttons.Close())
                    .Draggable(true)
                    .Visible(false)
                    .Modal(true)
                    .Title("Post")
                    .Width(850)
                    .Height(400))

The above given window is opened when the add button on the grid's toolbar is clicked. The java script to open the popup is given below.

function AddNewPost(clientid) {
    OpenPostAddEditWindow("Add New Post",0, clientid);
}

function OpenPostAddEditWindow(title, id, clientId) {   
   var window = $("#window").data("kendoWindow");
   window.content({ url: "/Post/Manage/Edit",
       data: { id: 0, clientId: -1112}
   });     
 
   window.title("New Post");
    debugger;
    alert(window.content());
    window.center();
    window.open();
}

when we were using telerik window, the code we used is as given below:

function OpenPostAddEditWindow(title, id,clientId) {
    var url = $.Site.RelativeWebRoot + "Post/Manage/Edit?id=" + id + "&clientId=" + clientId;
    var windowElement = $.telerik.window.create({
        Name: "PostWindow",
        title: title,
        html: '',
        contentUrl: url,
        modal: true,
        resizable: false,
        width: 850,
        height: 400,
        draggable: true,
        onClose: function (e) {
            e.preventDefault();
            windowElement.destroy();
        },
        onRefresh: function (e) {
            windowElement.center();
        }
    }).data('tWindow');
    windowElement.center().open();

}

how can we make it work same as telerik window and how to call an action in the controller given in the url.Please review this and send us the feedback as early as possible.

Thanks
Nirmala
Daniel
Telerik team
 answered on 03 Dec 2012
1 answer
271 views
avatar
I want to set the  width of a currency text box.  I am using the legacy WebBlue theme.

I have tried
<%: Html.Kendo().CurrencyTextBoxFor(x => x.Charged).HtmlAttributes(new { style = "width:100px" }) %>

but that just cuts off the right hand edge.

I have tried the approach in
http://www.kendoui.com/forums/mvc/numeric-textbox/set-width-on-client-side.aspx
 but that doesn't work either.
Vladimir Iliev
Telerik team
 answered on 03 Dec 2012
3 answers
205 views
I'm trying to retrieve the begin and end dates of the current calendar, but I can't determine the property or method.  I'm using JQuery and am able to retrieve the current month using

$(

 

"#myCalendar").kendoCalendar().data("kendoCalendar")._current.getMonth()

 

Any help would be greatly appreciated!
Georgi Krustev
Telerik team
 answered on 03 Dec 2012
1 answer
78 views
The documentation might need to be updated for the KendoUI and MVC helpers..

The online docs here:  http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/helpers/upload/metadata

Talk about binding client side events to the KendoUI MVC helpers.
using .ClientEvents()

After intellisense complaining and digging into it more I realized that its actually .Events() with a slightly different signature. 

Please keep the online documentation up to date with the releases.   thanks!

For reference I am using the 2012.3.1114.340 release.
T. Tsonev
Telerik team
 answered on 03 Dec 2012
3 answers
182 views
hello,

i'm looking to render a Barcode like 

<telerik:radbarcode runat="server" Height="112px" ShowChecksum="False" ShowText="False" Text="DccPGDqsRRMA" Type="Code128A" Width="463px"></telerik:radbarcode>

is there a way to use the radbarcode in the razor engine?

using MVC 4 with Kendo complete for MVVC

Thanks 

Atanas Korchev
Telerik team
 answered on 03 Dec 2012
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
Dialog
MultiColumnComboBox
DropDownTree
Checkbox
Slider
Switch
Notification
Accessibility
ListView (Mobile)
Pager
ColorPicker
DateRangePicker
Security
Wizard
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
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?