Telerik Forums
Kendo UI for jQuery Forum
1 answer
200 views
I would like to pass the filter and sort criteria to an action using a toolbar custom command. Ultimately, I'd like to export a CSV or Excel file. What is the best way to go about this?

I first tried the following, but it did not work.

The view
@(Html.Kendo().Grid<KendoGridApplication.Models.Order>()
      .Name("Grid")
      .ToolBar(o => o.Custom().Action("Export", "Home").Name("Export"))
      ...

The controller
public ActionResult Export([DataSourceRequest] DataSourceRequest request)
{
  // request.Filters is null
  // request.Sorts is null
Petur Subev
Telerik team
 answered on 03 Aug 2012
0 answers
192 views
Hi Guys, Im trying to refactor my javascript to fit the Revealing Module Pattern, but am coming up with a few issues. To start with following is my viewModel function:

/***********************************/
function Contacts_Details_ViewModel(SelectedContactID) {  
    var self = this;
    var selectedContact;
    var selectedContactID = SelectedContactID;
    var contacts_Details_DataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: $('#urlLink').data('url') + '?tenantID=1&dataType=Contacts_Details',
                dataType: "json",
                data: {
                    actionName: function () {                        
                        return selectedContactID;
                    }
                }
            },
            update: {
                url: $('#urlLink').data('url') + '/SaveChanges?tenantID=1&actionName=Contacts_Details',
                dataType: "json",
                type: "POST",
                contentType: "application/json; charset=utf-8"
            },
            parameterMap: function (options, operation) {
                if (operation !== "read" && options.models) {
                    return JSON.stringify(options.models);
                }
                return options;
            }
        },
        batch: true, 
        change: function () {
            selectedContact = this.view()[0];                        
        },
        schema: {
            model: {
                id: "ContactID"
       }
        }
    });
    contacts_Details_DataSource.read();
    var goToContactsListing = function () {        
        this.selectedContactID = null;
        location.hash = ''
    }

    var change = function () {
        hasChanges = true;        
    }

    var hasChanges = false;

    var saveChanges = function () {
        contacts_Details_DataSource.sync();
        hasChanges = false;        
    }

    return {
        contacts_Details_DataSource: contacts_Details_DataSource,
        selectedContact: selectedContact,
        goToContactsListing: goToContactsListing,
        change: change,
        hasChanges: hasChanges,
        saveChanges: saveChanges
    };
}
/***********************************/ 

Than I have the following to initialize the Contacts View Model:

/***********************************/ 
$(document).ready(function () {
    var contacts_Details_ViewModel = kendo.observable(new Contacts_Details_ViewModel(1));
    kendo.bind($("#ContactsDetails"), contacts_Details_ViewModel);
});
/***********************************/  

Than I have the following html on the page that binds to the view model
/***********************************/  
<div id="ContactsDetails" >
    <ul>
            <li><label>ID</label> <span data-bind="text:selectedContact.ContactID, events: { change: change }"></span></li>
            <li><label>Name</label> <input type="text" class="k-textbox" data-bind="value: selectedContact.FirstName, events: { change: change }" /></li>
            <li><label>UnitPrice</label> <input type="text" class="k-textbox" data-bind="value: selectedContact.LastName, events: { change: change }" /></li>
        </ul>
        <button data-bind="click: goToContactsListing">Back to Listing</button>
         <button data-bind="click: saveChanges, enabled: hasChanges">Save Changes</button>
</div>
/***********************************/  

My problem is nothing ever shows up in the SelectedContact fields (ID label and firstname lastname textboxes), they are always blank. Everything else seems to be bound correctly (events and simple strings work fine) but just not the selectedContact.

Any ideas on where Im going wrong? Im thinking whether it is how I set the selectedContact var in the change event of the datasource, im not confident that its being set there correctly.

Please help I've waisted a day trying to get this to work, so ive got to tap out for my own sanity.

Thanks in advance




Matt
Top achievements
Rank 1
 asked on 03 Aug 2012
5 answers
862 views
Hi,
I want to have a input text box with search enabled just like the type='search' input box available in the jquerymobile.
i.e. No need to have the search button next to it, but it turns the iPhone return button into the search button.

http://jquerymobile.com/demos/1.1.0/docs/forms/search/index.html 

Would it be possible to do this in Kendo Mobile view?

alternatively, I wouldn't mind using the jquerymobile directly in my Kendo Mobile view if possible(I tried this ,, <input type='search' /> and didn't work. 

Any help would be much appreciated,

Regards,

JOhn C
Joon
Top achievements
Rank 1
 answered on 03 Aug 2012
2 answers
144 views
Hi,

Is there a method available to smooth the pointer's transition between values in a radial gauge?

For example, if I set the value to 0 and then click to change the value to 100, the needle seems to very quickly (almost instantly) jump to the 100 position. This results in a unrealistic gauge. Is there a way to slow the animation?

I have tried the suggestion seen in another thread here, but it seemed to have no effect:

        animation: {
            duration: 10 // milliseconds that the animation will take to play
        } 

Thanks.
Dave
Top achievements
Rank 1
 answered on 03 Aug 2012
0 answers
179 views
Hi
Using the TabStrip UI element in our ASP.NET MVC 3 application using the Razor engine and binding the control to an IEnumerable<T> we noticed the following behaviour.
  • Using a FOR loop on the IEnumerable<T> to generate the Tab Items (Tab pages) works fine
  • But setting the Tab Item Content within the same loop for some reason causes some kind of a deferred execution, the contents seem to be set after the tab pages are created (which I assume is related to the load-on-demand feature of the tabstrip)
  • The problem is, the iteration seem to be using the last element in the model to set the content of all the tab pages.

Here is the sample code, could you please direct to the mistake in it or the right method using razor to acheive the same.

@model IEnumerable<KendoMVCExample.Models.CustomerAddress>
...
@(Html.Kendo().TabStrip()
    .Name("CustomerAddressTabStrip")
    .Items(items =>
    {
        foreach (var customer in Model)
        {
            items.Add()
            .Content(@<text> @RenderTableContent(customer) </text>)//<----this fails {last address is repeated on all} 
            .Text(customer.CustomerName); //<----this works fine 
        }        
    }).SelectedIndex(0)
    )
 
     @helper RenderTableContent(KendoMVCExample.Models.CustomerAddress customer)
         {
          <table>
             <tr>
                 <td>
                     @customer.AddressLine1<br />
                     @customer.AddressLine2<br />
                     @customer.AddressLine3<br />
                 </td>
             </tr>
         </table>
    }
Prabhat
Top achievements
Rank 1
 asked on 03 Aug 2012
0 answers
152 views
In editor, How Do I Add A Background Image To My TextArea? How to change backgroundcolor of a textarea?

this way don't work: 
<textarea id="editor" rows="10" cols="30" style="width:710px; height:750px; background-image:url(layout.jpg); background-repeat:no-repeat;">
</textarea>
Eduardo
Top achievements
Rank 1
 asked on 03 Aug 2012
5 answers
208 views
http://demos.kendoui.com/calendar/template.html

I began implementing a variation on the demo example using almost an identical array of dates. I noticed that all my dates were adding the template a month ahead of the date I configured. But, then I went back and looked back at the example and noticed that it's doing the same there.

Here's my code (also added a screen shot of the month the dates are rendering):

var assignments = [
        +new Date(2011, 12, 6),
        +new Date(2011, 11, 27),
        +new Date(2011, 11, 24),
        +new Date(2011, 11, 16),
        +new Date(2011, 11, 11)
];
 
$("#calendar").kendoCalendar({
    value: new Date(),
    month: {
        // template for dates in month view
        content: '# if ($.inArray(+data.date, [' + assignments + ']) != -1) { #' +
            '<div class="assignment"></div>' +
            '# } #' +
            '#= data.value #'
    },
    change: onCalendarChange,
    footer: "Today - #=kendo.toString(data, 'd') #"
});
Jelena
Top achievements
Rank 1
 answered on 02 Aug 2012
1 answer
225 views
I have a kendoGrid to display fields as text boxes and I would like to use validation on the input text boxes using kendoValidator.
I would expect to see a message against each text box but only one validation message is reused for each cell.
How do we use the kendoValidator within kendoGrid that uses a row template and generates input tags for each fields.
I have attached a sample file with a grid and validation within it.
Suresh
Top achievements
Rank 1
 answered on 02 Aug 2012
0 answers
338 views
I get the error that the username variable is not defined.
Below is what is in the source:  I have tried various casing for the username.
When I get the undefined error, I can pass my variable, but I cannot page because of the error.
If I remove the error by making my variable all lowercase, the passed in variable is null.

function anonymous(data) {
var o,e=kendo.htmlEncode;with(data){o='<tr data-uid="'+(uid)+'"><td ><a href=\'/Admin/Admin/GetUserRoles/UserName='+(username)+'\'>'+(UserName)+'</a></td><td >'+(e(Email))+'</td><td >'+(e(IsApproved))+'</td><td >'+(e(IsLockedOut))+'</td><td >'+(e(IsOnline))+'</td><td >'+(e(LastLoginDate))+'</td></tr>';}return o;
}

My entire View is below:

@model IList<DsTow.Presentation.Areas.Admin.ViewModel.UserViewModel>
@using Kendo.Mvc.UI
@using DsTow.Presentation.Areas.Admin.ViewModel

@{
    ViewBag.Title = "Users";

    var rolesview = @ViewBag.RolesView;
}
<h2>
    Users</h2>
<div>
    <table>
        <tr>
            <td>
                @Html.ActionLink("All", "FindUsersByText", "Admin", new { area = "Admin", val = "All" }, null)
            </td>
            <td>
                @Html.ActionLink("A", "FindUsersByText", "Admin", new { area = "Admin", val = "A" }, null)
            </td>
            <td>
                @Html.ActionLink("B", "FindUsersByText", "Admin", new { area = "Admin", val = "B" }, null)
            </td>
            <td>
                @Html.ActionLink("C", "FindUsersByText", "Admin", new { area = "Admin", val = "C" }, null)
            </td>
            <td>
                @Html.ActionLink("D", "FindUsersByText", "Admin", new { area = "Admin", val = "D" }, null)
            </td>
            <td>
                @Html.ActionLink("E", "FindUsersByText", "Admin", new { area = "Admin", val = "E" }, null)
            </td>
            <td>
                @Html.ActionLink("F", "FindUsersByText", "Admin", new { area = "Admin", val = "F" }, null)
            </td>
            <td>
                @Html.ActionLink("G", "FindUsersByText", "Admin", new { area = "Admin", val = "G" }, null)
            </td>
            <td>
                @Html.ActionLink("H", "FindUsersByText", "Admin", new { area = "Admin", val = "H" }, null)
            </td>
            <td>
                @Html.ActionLink("I", "FindUsersByText", "Admin", new { area = "Admin", val = "I" }, null)
            </td>
            <td>
                @Html.ActionLink("J", "FindUsersByText", "Admin", new { area = "Admin", val = "J" }, null)
            </td>
            <td>
                @Html.ActionLink("K", "FindUsersByText", "Admin", new { area = "Admin", val = "K" }, null)
            </td>
            <td>
                @Html.ActionLink("L", "FindUsersByText", "Admin", new { area = "Admin", val = "L" }, null)
            </td>
            <td>
                @Html.ActionLink("M", "FindUsersByText", "Admin", new { area = "Admin", val = "M" }, null)
            </td>
            <td>
                @Html.ActionLink("N", "FindUsersByText", "Admin", new { area = "Admin", val = "N" }, null)
            </td>
            <td>
                @Html.ActionLink("O", "FindUsersByText", "Admin", new { area = "Admin", val = "O" }, null)
            </td>
            <td>
                @Html.ActionLink("P", "FindUsersByText", "Admin", new { area = "Admin", val = "P" }, null)
            </td>
            <td>
                @Html.ActionLink("Q", "FindUsersByText", "Admin", new { area = "Admin", val = "Q" }, null)
            </td>
            <td>
                @Html.ActionLink("R", "FindUsersByText", "Admin", new { area = "Admin", val = "R" }, null)
            </td>
            <td>
                @Html.ActionLink("S", "FindUsersByText", "Admin", new { area = "Admin", val = "S" }, null)
            </td>
            <td>
                @Html.ActionLink("T", "FindUsersByText", "Admin", new { area = "Admin", val = "T" }, null)
            </td>
            <td>
                @Html.ActionLink("U", "FindUsersByText", "Admin", new { area = "Admin", val = "U" }, null)
            </td>
            <td>
                @Html.ActionLink("V", "FindUsersByText", "Admin", new { area = "Admin", val = "V" }, null)
            </td>
            <td>
                @Html.ActionLink("W", "FindUsersByText", "Admin", new { area = "Admin", val = "W" }, null)
            </td>
            <td>
                @Html.ActionLink("X", "FindUsersByText", "Admin", new { area = "Admin", val = "X" }, null)
            </td>
            <td>
                @Html.ActionLink("Y", "FindUsersByText", "Admin", new { area = "Admin", val = "Y" }, null)
            </td>
            <td>
                @Html.ActionLink("Z", "FindUsersByText", "Admin", new { area = "Admin", val = "Z" }, null)
            </td>
        </tr>
    </table>
    <table>
        <tr>
            <td>
                <div id="Users_Container">
                    @(Html.Kendo().Grid(Model)
                       .Name("UserGrid")
                       .Columns(columns =>
                       {

                           columns.Template(
                            @<text>
                                    @Ajax.ActionLink(@item.UserName, "GetUserRoles", "Admin", new { username = @item.UserName },  new AjaxOptions{ UpdateTargetId="roleResults"}, null)
                           </text>).Title("User Name").ClientTemplate("<a href='/Admin/Admin/GetUserRoles/UserName=#=username#'>#=UserName#</a>"); causing error
                                                
                           columns.Bound(p => p.Email)
                          .Width(120)
                          .Title("Email");
                           columns.Bound(p => p.IsApproved)
                          .Width(120)
                          .Title("IsApproved");
                           columns.Bound(p => p.IsLockedOut)
                          .Width(120)
                          .Title("IsLockedOut");
                           columns.Bound(p => p.IsOnline)
                          .Width(120)
                          .Title("IsOnline");
                           columns.Bound(p => p.LastLoginDate)
                          .Width(120)
                          .Title("LastLoginDate");
                          
                       })
                         .DataSource(dataSource => dataSource
                         .Ajax() // Specify that the data source is of ajax type                                            
                         .Read(read => read.Action("Users_Read", "Admin", new { val = ViewBag.Val }).Data("additionalData"))// Specify the action method and controller name                                                  
                         .PageSize(2))
                         .Pageable())
                    <script type="text/javascript">
                        function additionalData() {
                            return {

                            };
                        }
                    </script>
                </div>
                <div>                   
                 <div id="roleResults" />                     
                </div>
            </td>
        </tr>
    </table>
</div>

My controller is below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.Mvc;
using System.Web.Security;
using DsTow.Presentation.Repositories;
using DsTow.Presentation.Repositories.Core;
using AutoMapper;
using DsTow.Presentation.Areas.Admin.ViewModel;
using DsTow.Presentation.Infrastructure;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI;
using DsTow.Presentation.Areas.Admin.Models;

namespace DsTow.Presentation.Areas.Admin.Controllers
{
    public class AdminController : DsTowBaseController
    {
        private IUserRepository usersRepository;
         
        public AdminController(IUserRepository usersRepository)
        {
            this.usersRepository = usersRepository;

        }

        public ActionResult Index()
        {
            return View();
        }
        //
        // GET: /Admin/Admin/

        public ActionResult FindUsersByText(string val)
        {
            ViewBag.Val = val;
            if (val != "All" && !string.IsNullOrEmpty(val))
            {
                MembershipUserCollection  users = this.usersRepository.FindUsersByText(val);


                IEnumerable<UserViewModel> userview =
                        Mapper.Map<IEnumerable<MembershipUser>, IEnumerable<UserViewModel>>(users.Cast<MembershipUser>().AsEnumerable());                
 
                return View("Users", userview);
            }
            else
            {
                MembershipUserCollection users = this.usersRepository.FindAllUsers();


                IEnumerable<UserViewModel> userview =
                   Mapper.Map<IEnumerable<MembershipUser>, IEnumerable<UserViewModel>>(users.Cast<MembershipUser>().AsEnumerable());
                

                return View("Users", userview);
            }

           
        }

        public PartialViewResult GetUserRoles(string username)
        {

            var results = this.usersRepository.GetUserRoles(username);  
            var result = Mapper.Map<IEnumerable<UserRoles>, IEnumerable<UserRolesViewModel>>(results.AsEnumerable());
            return PartialView("_UserDetails", result);            
        }
        //public ActionResult Roles_Read([DataSourceRequest]DataSourceRequest request, string val)
        //{

        //    MembershipUserCollection users = this.usersRepository.FindUsersByText(val);
        //    IEnumerable<UserViewModel> userview =
        //         Mapper.Map<IEnumerable<MembershipUser>, IEnumerable<UserViewModel>>(users.Cast<MembershipUser>().AsEnumerable());


        //    return Json(userview.FirstOrDefault().Roles.ToDataSourceResult(request, ModelState));
        //}

        public ActionResult Users_Read([DataSourceRequest]DataSourceRequest request, string val)
        {                        
            if (val != "All" && !string.IsNullOrEmpty(val))
            {
                MembershipUserCollection users = this.usersRepository.FindUsersByText(val);

                IEnumerable<UserViewModel> userview =
                        Mapper.Map<IEnumerable<MembershipUser>, IEnumerable<UserViewModel>>(users.Cast<MembershipUser>().AsEnumerable());
                return Json(userview.ToDataSourceResult(request, ModelState));                
            }
            else
            {
                MembershipUserCollection users = this.usersRepository.FindAllUsers();


                IEnumerable<UserViewModel> userview =
                   Mapper.Map<IEnumerable<MembershipUser>, IEnumerable<UserViewModel>>(users.Cast<MembershipUser>().AsEnumerable());

               
                return Json(userview.ToDataSourceResult(request, ModelState));               
            }
                       


        }


    }
}


I have no idea why this is occurring.  It looks right to me.  I think it is a bug in Kendo.
King
Top achievements
Rank 1
 asked on 02 Aug 2012
7 answers
913 views
Hello 
I have multiple series running on a graph of type line . now my client requires that the visibility of each of the series be externally controlled. that is for example if i have a div or li list of series somewhere on the page clicking them i should be able to toggle the visibility of respective series on the graph . for example clicking <div>series A</div> should toggle the visibility of 'series A' on the graph.
I wonder if this is in the scope of the kendo dataviz
Guillermo
Top achievements
Rank 1
 answered on 02 Aug 2012
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Drag and Drop
Application
Map
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
ListBox
DropDownTree
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
PivotGridV2
Licensing
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
BottomNavigation
Ripple
SkeletonContainer
Avatar
Circular ProgressBar
FlatColorPicker
SplitButton
Signature
Chip
ChipList
VS Code Extension
AIPrompt
PropertyGrid
Sankey
Chart Wizard
OTP Input
SpeechToTextButton
InlineAIPrompt
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
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?