Telerik Forums
Kendo UI for jQuery Forum
0 answers
300 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
850 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
7 answers
202 views
Create an area chart with multiple sequences.
add a seriesClick function to the json configuration.

You'll notice that both the tooltip and the seriesClick functionality only recognize the highest value series.  The lower value series never get a tooltip and never can get clicked on.  This is apparent on the example page at
http://demos.kendoui.com/dataviz/area-chart/index.html

Is there a workaround for this?
Iliana Dyankova
Telerik team
 answered on 02 Aug 2012
0 answers
96 views

What's the proper markup for the column titles to bind them to a variable?  Basically, I'm looking to localize the column titles pulling them from a resource file.  My only problem is figuring the correct markup to display the header.

I know this works
<div id="CityCodeGridView" data-role="grid" data-bind="source: gridDataSource" data-sortable="true"
       data-editable="true" data-toolbar='["save", "cancel"]' data-columns='[{"field": "CityAlpha", "title": "city code" },
                                                                                    {"field": "CityNumeric", "title": "iata city code"},
                                                                                    {"field": "Description", "title": "description"},
                                                                                    {"field": "NextFlightEnabled", "title": "next flight enabled"},
                                                                                    {"command": "destroy"}]'
       data-scrollable="false">
    
</div>

but I'm looking for something like this
<div id="CityCodeGridView" data-role="grid" data-bind="source: gridDataSource" data-sortable="true"
       data-editable="true" data-toolbar='["save", "cancel"]' data-columns='[{"field": "CityAlpha", "title": userMsgs.CityCode },
                                                                                    {"field": "CityNumeric", "title": userMsgs.IataCityCode},
                                                                                    {"field": "Description", "title": userMsgs.Description},
                                                                                    {"field": "NextFlightEnabled", "title": userMsgs.NextFlightEnabled},
                                                                                    {"command": "destroy"}]'
       data-scrollable="false">
    
</div>
where the title is a member property.  Thanks.
Tina
Top achievements
Rank 1
 asked on 02 Aug 2012
0 answers
118 views
My rest service is expecting something like this:

'{ data1: "value1", data2: "value2"}'

Using the dataSource.transport.create method, my rest service receives something like this:

'data1=value1&data2=value2'

I've looked through the forums but have had no luck in getting the method to call jquery.ajax() with the proper data. How do I do this?
Matt
Top achievements
Rank 1
 asked on 02 Aug 2012
1 answer
69 views
How can i make my javascript code run every time the page (page1.html) is shown to the user? Just including the script or using $(document).ready only runs the script the first time the page is shown.
Robin
Top achievements
Rank 1
 answered on 02 Aug 2012
0 answers
127 views
I am new to the Kendo UI so I may not know how best to phrase my question.  I have setup validation for my grid to be used during inline edits.  I would to use this same validation for a user form as well.  No one likes to code the same thing twice.  Any ideas of how I can do that?

My validation for the grid:

var cityCodesModel = {
    id: "CityAlpha",
    fields: {
        CityAlpha: {
            type: "string",
            validation: {
                required: { message: "city alpha code is required" },
                cityAlphacheckLength: function (input) {
                    input.attr("data-cityAlphacheckLength-msg", "a city alpha code must be 3 characters");
                    var ret = true;
                    if (input.is("[name=CityAlpha]")) {
                        ret = input.val().length == 3;
                    }
                    return ret;
                }
            }
        },

        CityNumeric: {
            type: "string",
            validation: {
                required: { message: "city numeric code code is required" },
                cityNumericCheckLength: function (input) {
                    input.attr("data-cityNumericCheckLength-msg", "a city numeric code must be 4 characters");
                    var ret = true;
                    if (input.is("[name=CityNumeric]")) {
                        ret = input.val().length == 4;
                    }
                    return ret;
                },
                cityNumericIsNumeric: function (input) {
                    input.attr("data-cityNumericIsNumeric-msg", "a city numeric code must be numeric");
                    var ret = true;
                    if (input.is("[name=CityNumeric]")) {
                        ret = !isNaN(input.val());
                    }
                    return ret;
                }
            }
        },

        Description: { type: "string",
            validation: {
                required: false,
                descriptionCheckLength: function (input) {
                    input.attr("data-descriptionCheckLength-msg", "a description cannot be longer than 80 characters");
                    var ret = true;
                    if (input.is("[name=Description]")) {
                        ret = input.val().length <= 80;
                    }
                    return ret;
                }
            }
        },
       
        NextFlightEnabled: { type: "boolean" }
    }
};

Brad
Top achievements
Rank 1
 asked on 02 Aug 2012
0 answers
174 views
Hi All,

I am using remote datasource and binding this by using Odata service.

Example for Odata service: 
_WebServiceAddress + "dataapi/ProductGroupProducts?$orderby=Name&$filter=ProductGroupId eq guid'" + tSelectedId + "'"

and i am trying to filter datasource server side by using datasource filter option. 
Example: 

   $("#DivProductGroupDetailsTable").data("kendoGrid").dataSource.filter({
            logic: "or",
            filters: [
                    { field: "Name", operator: "contains", value: pSearchValue },
                    { field: "DataMatchKey", operator: "contains", value: pSearchValue }
                ]
        });

but i am getting following error:
":"Query parameter '$filter' is specified, but it should be specified exactly once."

Please advise.

Thank you in advance.

regards,
Shankar
Shankar
Top achievements
Rank 1
 asked on 02 Aug 2012
7 answers
4.7K+ views
So I've got a Kendo Grid initialized like so:
var custData = {
    "columns": [
        { "field": "ID", "title": "ID", "filterable": true, "width": 1 },
        { "field": "Last", "title": "Last", "filterable": true, "width": 1 },
        { "field": "Middle", "title": "Middle", "filterable": true, "width": 12 },
        { "field": "First", "title": "First", "filterable": true, "width": 1 },
        { "field": "Role", "title": "Role", "filterable": true, "width": 1 },
        { "field": "Rank", "title": "Rank", "filterable": true, "width": 1 }
    ],
    "data": [/* Lots of data here, organized like so: */
        { "ID": "00011", "Last": "Picard", "Middle": "", "First": "Jean Luc", "Role": "Commanding Officer", "Rank": "Captain" }
    ]
};
var custDataSource = new kendo.data.DataSource({
    pageSize: 10,
    data: custData["data"]
});
$("#customers").kendoGrid({
    height: 600,
    width: 800,
    columns: custData["columns"],
    dataSource: custDataSource,
    groupable: true,
    scrollable: false,
    sortable: {
        mode: "multiple",
        allowUnsort: true
    },
    pageable: true,
    selectable: "multiple row",
    nagivatable: true,
    toolbar: [
        { name: "create", text: "New" },
        { name: "save", text: "Save" },
        { name: "cancel", text: "Cancel" },
        { name: "destroy", text: "Delete" }
    ],
    editable: {
        update: true,
        destroy: false,
        confirmation: "Are you sure you want to remove this item?"
    }
});

I'm trying to get a grid with a static height and width. It absolutely must not change height and width when I page (which it currently does, due to variably-sized data). The same is true of the data cells. They absolutely must not change size or shape, but they do anyway. I tried setting static width and height, but it seems to be ignoring them to some degree. Beyond that, the column widths are not defining the widths of the columns, but rather the number of pixels to add to the width of the column. Also, it doesn't actually add the specified number of pixels, but some seemingly arbitrary number any given time.

When there's too much data in a cell, it wraps, making the row taller, and thus changing the height of the Grid. That is unacceptable. I require a static height and width, and perhaps it could show the full contained value of the cell on mouseover. I need the values to not wrap or overflow in any way. Is there some way to achieve this?

When paging, the column widths change, throwing off the data alignment. It just looks bad, visually, to be paging through the data, and seeing the column widths changing (and the height of the Grid changing in response to taller rows, too).

Things I need to accomplish, broken out into a list:
  • Static column or cell widths
  • No wrapping of cell content, and no resulting overflow either (white-space: nowrap; overflow: hidden;)
  • Static row or cell heights
  • Static overall Grid height (cannot have scrolling Grids, because may be viewed on mobile platform where scrolling in child containers does not function)
How can I achieve those goals without too much hackery? I'm willing to add a CSS style to address the cell overflow and wrapping issues if necessary, but how about the column/cell widths and row/cell heights? I'm sure that the overall height issue will resolve itself once my rows stop changing height.

Thank you.

Best Regards,

Adrian
Adrian
Top achievements
Rank 1
 answered on 02 Aug 2012
0 answers
50 views
Hi All,

I am using remote datasource and binding this by using Odata service.

Example for Odata service: 
_WebServiceAddress + "dataapi/ProductGroupProducts?$orderby=Name&$filter=ProductGroupId eq guid'" + tSelectedId + "'"

and i am trying to filter datasource server side by using datasource filter option. 
Example: 

   $("#DivProductGroupDetailsTable").data("kendoGrid").dataSource.filter({
            logic: "or",
            filters: [
                    { field: "Name", operator: "contains", value: pSearchValue },
                    { field: "DataMatchKey", operator: "contains", value: pSearchValue }
                ]
        });

but i am getting following error:
":"Query parameter '$filter' is specified, but it should be specified exactly once."

Please advise.

Thank you in advance.

regards,
Shankar
Shankar
Top achievements
Rank 1
 asked on 02 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?