Telerik Forums
Kendo UI for jQuery Forum
5 answers
662 views
Hi,
I have the following code which is far as I can tell as per the documentation and examples but the listview always appears empty.
My View is as follows
@model iProjX.Models.RolesModel
@using iProjX.Models;
 
<script type="text/x-kendo-tmpl" id="rolesList">
    <h3> ${Id} ${Description}</h3>
</script>
 
<div id="listView"></div>
<div class="k-pager-wrap">
    <div id="pager"></div>
</div>
 
 
<script type="text/javascript">
    var projectId = @(Html.Raw(Model.ProjectId));
 
    var sharedDataSource = new kendo.data.DataSource({
        transport: {
                read: {
                    url: "http://localhost:1278/Project/getRoles",
                    type: "POST"
                }
        },
        change: function (data) {
            debugger;
            alert("success ");
        },
        error: function (xhr, error) {
            debugger;
            alert("error ");
        },
        pageSize: 3
    });
 
    //Configure the List
    $("#listView").kendoListView({
        pageable: true,
        selectable: true,
        navigatable: true,
        template: kendo.template($("#rolesList").html()),
        dataSource: sharedDataSource
    });
 
    //Configure the Pager
    $("#pager").kendoPager({
        dataSource: sharedDataSource
    });
      
</script>

 

And my controller contains

public JsonResult getRoles([DataSourceRequest] DataSourceRequest request)
{
    var projectId = 113;
    using (LocationRepositry _locationRepository = new LocationRepositry())
    {
        IEnumerable<myLocation> Locations = _locationRepository.getByProjectId_Simple(projectId).Select(p =>     new     myLocation()
        {
            Id = p.Id,
            Description = p.Description
        }).ToList();
        return Json(Locations.ToDataSourceResult(request));
     }
}

And myLocation is

public class myLocation
{
    public myLocation() {}
 
    public Int64 Id { get; set; }
    public String Description { get; set; }
}

Now, with this implementation my controller function getRoles is hit and I can see the data returned from the server via browser tools as below.

Data returned from server
{"Data":[{"Id":132,"Description":"Location 1"},{"Id":133,"Description":"Location 2"},{"Id":134,"Description":"Location 3"},{"Id":135,"Description":"Location 4"}],"Total":4,"AggregateResults":null,"Errors":null}

The change function on the datasource is then subsequently hit but the data parameter returned contains an empty set of Data items as below (taken from visual studio immediate window).

?data
{...}
    items: []
    sender: {...}
    preventDefault: function(){g=!0}
    isDefaultPrevented: function(){return g}



If I change my controller to return without using the ToDataSourceResult extension it actually will work.
    return Json(Locations);

However, is this then the correct implementation or have I done something else wrong? And would this have an effect on how paging works?

Any help would be much appreciated.
Thanks

 

 

 

sapan
Top achievements
Rank 1
 answered on 16 Nov 2012
0 answers
129 views
evaluating kendo ui

on OSX with Safari 4

using free download files dated 10 July 12 viz. kendoui/examples/web/dropdownlist/index.html

if you duplicate the 4 no. cap size options twice to give 12 options the scrollbar is displayed but locked.

similar lock happens for combobox / autocomplete / timepicker with when scrollbar added

can this be fixed ?

1.
if you show the display:none list with $("#dropdownlist-list").show() the scrollbar is working

2.
possible workaround is to replace scrollbar

$("#dropdownlist-list").css({width:100}).jScrollPane(); which does not display scrollbar

$("#dropdownlist-list").mouseenter(function(){

$(this).css({width:100}).jScrollPane();

}).mouseleave(function(){

$(this).hide();
});
Michael
Top achievements
Rank 1
 asked on 16 Nov 2012
1 answer
228 views
Just noticed a small bug in validating a checkbox. 

To replicate in demo:
1. tab to checkbox
2. click checkbox with mouse

Result: A checked box with error message (as if it wasn't checked).
Rosen
Telerik team
 answered on 16 Nov 2012
0 answers
101 views
Hi,
Can i create a DropDown Menu how KendoUI Menu Products ??

Vitantonio
Top achievements
Rank 1
 asked on 16 Nov 2012
0 answers
93 views
Hi,

I'm currently populating a label with the values entered into a numerictextbox, i can get the numeric values fine, but i would like to retrieve it together with the formatting as well. eg. numerictextbox showing $1,234.00 should be retrieved as displayed into a label. Thanks.
Justin
Top achievements
Rank 1
 asked on 16 Nov 2012
1 answer
85 views
Hi,

I tried the Kendo Grid (2012.2.710) with the following example for MVC 4. However, the command button Add New Record does not work (not effect when mouse over, click nothing happens) for Firefox, but it works for Chrome. But if it is plain html , it works fine for both.

I am not sure what could be problem? Appreciate if someone can help.

Thanks

 <div id="example" class="k-content">
            <div id="grid"></div>


            <script>
                $(document).ready(function () {
                    var crudServiceBaseUrl = "http://demos.kendoui.com/service",
                        dataSource = new kendo.data.DataSource({
                            transport: {
                                read: {
                                    url: crudServiceBaseUrl + "/Products",
                                    dataType: "jsonp"
                                },
                                update: {
                                    url: crudServiceBaseUrl + "/Products/Update",
                                    dataType: "jsonp"
                                },
                                destroy: {
                                    url: crudServiceBaseUrl + "/Products/Destroy",
                                    dataType: "jsonp"
                                },
                                create: {
                                    url: crudServiceBaseUrl + "/Products/Create",
                                    dataType: "jsonp"
                                },
                                parameterMap: function (options, operation) {
                                    if (operation !== "read" && options.models) {
                                        return { models: kendo.stringify(options.models) };
                                    }
                                }
                            },
                            batch: true,
                            pageSize: 30,
                            schema: {
                                model: {
                                    id: "ProductID",
                                    fields: {
                                        ProductID: { editable: false, nullable: true },
                                        ProductName: { validation: { required: true } },
                                        UnitPrice: { type: "number", validation: { required: true, min: 1 } },
                                        Discontinued: { type: "boolean" },
                                        UnitsInStock: { type: "number", validation: { min: 0, required: true } }
                                    }
                                }
                            }
                        });


                    $("#grid").kendoGrid({
                        dataSource: dataSource,
                        pageable: true,
                        height: 400,
                        toolbar: ["create"],
                        columns: [
                            "ProductName",
                            { field: "UnitPrice", title: "Unit Price", format: "{0:c}", width: "150px" },
                            { field: "UnitsInStock", title: "Units In Stock", width: "150px" },
                            { field: "Discontinued", width: "100px" },
                            { command: ["edit", "destroy"], title: "&nbsp;", width: "210px" }],
                        editable: "inline"
                    });
                });
            </script>
        </div>


tritue
Top achievements
Rank 1
 answered on 16 Nov 2012
3 answers
322 views
Hopefully this is an easy one :)

I have a "Membership" Controller that serves up a WebsiteUser obect defined as so:
public class WebsiteUser
{
    public string UserName { get; set; }
    public DateTime LoginTime { get; set; }
    public bool IsLoggedIn { get; set; }
}

This is served up from the Membership/Index route:

       
public ActionResult Index()
{
    List<WebsiteUser> Users = new List<WebsiteUser>();
    foreach (MembershipUser user in Membership.GetAllUsers())
    {
        Users.Add(
            new WebsiteUser()
            {
                UserName = user.UserName,
                IsLoggedIn = user.IsOnline,
                LoginTime = user.LastActivityDate
            });
    }
    return View(Users);
}


Which is populated thusly:
@model IEnumerable<ATFWebsite.Controllers.WebsiteUser>
 
@{
    ViewBag.Title = "Index";
}
 
<h2>Membership</h2>
 
@(Html.Kendo().Grid(Model)   
    .Name("Grid")
    .Columns(columns =>
    {
        columns.Bound(p => p.UserName).Groupable(false);
        columns.Bound(p => p.IsLoggedIn);
        columns.Bound(p => p.LoginTime);
    })
    .Groupable()
    .Pageable()
    .Sortable()
    .Scrollable()
    .Filterable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .Read(read => read.Action("Index", "Membership")
        )
    )
)


It all works quite nicely until I try to do paging, sorting or other ajax calls. The grid simply empties.

Whacking a breakpoint on the Index() call the page is definitely calling it back, but we're not getting the data. I assume I'm doing something elementary wrong here, unfortunately the Razor guides are still a little sparse on the ground and I'm having trouble finding a Razor example that does what I need.
Nathan
Top achievements
Rank 1
 answered on 15 Nov 2012
0 answers
117 views
Hello,

I was wondering if it is possible to have both popup editing and a dropdown editor in the same line in a grid. For instance;

...
columns: [ 
   { field: "ID", editor: devDropDownEditor, template: "#= selectID #" }, 
   { field: "Notes"}, 
   { command: "edit", width: 85}, 
],
editable: {mode: "popup", template: $("#popupTemplate").html()}
});

I have the dropdown editor working perfectly when the edit mode is incell. However, it does not work when the edit mode is popup, which is required for the rest of the grid. How can I get both working?

Thanks for your time.
Trevor
Top achievements
Rank 1
 asked on 15 Nov 2012
0 answers
71 views
i need help with this, im trying to make a area char with sources coming of a sql database y have a wcf service,  and the chart dont show me nothing

<div id="GAreaCPagos" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
    </div>
    <script type="text/jscript">


        function graficaCPagos() {

            $("#GAreaCPagos").kendoChart({
                theme: $(document).data("kendoSkin") || "default",
                dataSource: {
                    schema: {
                        data: "d", 
                        model: { 
                            fields: {
                                IDPAGOS: { type: "number" },
                                CANTPAGOS: { type: "number" }
                            }
                        }
                    },


                    transport: {


                        read: {
                            url: "ServicePagos.svc/ObtenerPagos",
                            contentType: "application/json; charset=utf-8", 
                            type: "POST" 
                        }
                    }
                },


                title: {
                    text: "Cantidad de Pagos",
                    color: "#848484"
                },


                legend: {
                    visible: true
                },


                seriesDefaults: {
                    type: "area"
                },


                series: [{ field: "CANTPAGOS"}],
                valueAxis: {
                    labels: {
                        format: "{0}"
                    }
                },


                categoryAxis: {
                    field: "IDPAGOS"
                },
                tooltip: {
                    visible: true,
                    format: "{0} Id"
                }
            });
        }

        $(document).ready(function () { var x = 0; graficaCPagos(); })
        
        
    </script>

help me please
David
Top achievements
Rank 1
 asked on 15 Nov 2012
0 answers
78 views
HI!
I need that someone make a good example about how to use a wcf service to bind data to a area chart datasource....using a sql server database..

should i have this

Grafica.aspx code:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Grafica.aspx.cs" Inherits="CantidadDePagos2.Grafica" %>


<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE htmlL>
<html>
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.7.2.min.js" type="text/javascript"></script>
    <script src="Scripts/kendo/2012.2.710/kendo.all.min.js" type="text/javascript"></script>
    <script src="Scripts/kendo/2012.2.710/kendo.dataviz.min.js" type="text/javascript"></script>
    <link href="Content/kendo/2012.2.710/kendo.common.min.css" rel="stylesheet" type="text/css" />
    <link href="Content/kendo/2012.2.710/kendo.default.min.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <div id="GAreaCPagos" runat="server">
     </div>
    <script type="text/jscript">


        function graficaCPagos() {

            $("#GAreaCPagos").kendoChart({
                theme: $(document).data("kendoSkin") || "default",
                dataSource: {
                    schema: {
                        data: "d", 
                        model: { 
                            fields: {
                                IDPAGOS: { type: "number" },
                                CANTPAGOS: { type: "number" }
                            }
                        }
                    },


                    transport: {


                        read: {
                            url: "ServicePagos.svc/ObtenerPagos"
                            contentType: "application/json; charset=utf-8"
                            type: "POST" 
                        }
                    }
                },


                title: {
                    text: "Cantidad de Pagos",
                    color: "#848484"
                },


                legend: {
                    visible: true
                },


                seriesDefaults: {
                    type: "area"
                },


                series: [{ field: "CANTPAGOS"}],
                valueAxis: {
                    labels: {
                        format: "{0}"
                    }
                },


                categoryAxis: {
                    field: "IDPAGOS"
                },
                tooltip: {
                    visible: true,
                    format: "{0} Id"
                }
            });
        }

        $(document).ready(function () { graficaCPagos(); })
        
        
    </script>
    </form>
</body>
</html>

ServicePagos.svc.cs code:

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.SqlClient;
using System.Data;


namespace CantidadDePagos2
{
public class ServicePagos : IServicePagos
{
    private string strConnection = ConfigurationManager.ConnectionStrings["cas"].ToString();
    public string GetData(int value)
{
return string.Format("You entered: {0}", value);
}


public CompositeType GetDataUsingDataContract(CompositeType composite)
{
if (composite == null)
{
throw new ArgumentNullException("composite");
}
if (composite.BoolValue)
{
composite.StringValue += "Suffix";
}
return composite;
}


    public List<IndiceMorosidad> ObtenerPagos()
    {
        List<IndiceMorosidad> pagos = new List<IndiceMorosidad>();
        using (SqlConnection con = new SqlConnection(strConnection))
        {
            con.Open();
            SqlCommand cmd = new SqlCommand("SELECT CodIndiceMorosidad, CantidadPagos FROM IndiceMorosidad", con);
            SqlDataAdapter dta = new SqlDataAdapter(cmd);
            DataTable dtresp = new DataTable();
            dta.Fill(dtresp);
            if (dtresp.Rows.Count > 0)
            {
                for (int i = 0; i < dtresp.Rows.Count; i++)
                {
                    IndiceMorosidad infopago = new IndiceMorosidad();
                    infopago.IDPAGOS = int.Parse(dtresp.Rows[i]["CodIndiceMorosidad"].ToString());
                    infopago.CANTPAGOS = int.Parse(dtresp.Rows[i]["CantidadPagos"].ToString());
                    pagos.Add(infopago);
                }
            }
            con.Close();
        }
        return pagos;
    }
}
}

and i have the IServicePagos with this code:

namespace CantidadDePagos2
{
    // NOTA: puede usar el comando "Rename" del menú "Refactorizar" para cambiar el nombre de interfaz "IServicePagos" en el código y en el archivo de configuración a la vez.
    [ServiceContract(Name = "CantidadDePagos2")]
    public interface IServicePagos
    {
        [OperationContract]
        List<IndiceMorosidad> ObtenerPagos();
    }


    [DataContract]
    public class IndiceMorosidad
    {
        int Id;
        int CPagos;


        [DataMember]
        public int IDPAGOS
        {
            get { return Id; }
            set { Id = value; }
        }


        [DataMember]
        public int CANTPAGOS
        {
            get { return CPagos; }
            set { CPagos = value; }
        }
    }
}

my web config is that:

<?xml version="1.0"?>
<!--
  Para obtener más información sobre cómo configurar la aplicación de ASP.NET, visite
  http://go.microsoft.com/fwlink/?LinkId=169433
  -->
<configuration>
  <connectionStrings>
    <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" />
    <add name="cas" connectionString="Data Source=localhost;Initial Catalog=CASWEB_2012_;Persist Security Info=True;User ID=cas;Password=123" providerName="System.Data.SqlClient" />
  </connectionStrings>
  <system.web>
    <compilation debug="true" targetFramework="4.0">
      <assemblies>
        <add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
        <add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
        <add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      </assemblies>
    </compilation>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login.aspx" timeout="2880" />
    </authentication>
    <membership>
      <providers>
        <clear />
        <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <profile>
      <providers>
        <clear />
        <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/" />
      </providers>
    </profile>
    <roleManager enabled="false">
      <providers>
        <clear />
        <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" />
        <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" />
      </providers>
    </roleManager>
    <httpHandlers>
      <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" />
    </httpHandlers>
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
    <validation validateIntegratedModeConfiguration="false" />
    <handlers>
      <add name="Telerik_Web_UI_WebResource_axd" verb="*" preCondition="integratedMode" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" />
    </handlers>
  </system.webServer>
  <system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_IServicePagos" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm="" />
            <message clientCredentialType="UserName" algorithmSuite="Default" />
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:56245/ServicePagos.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_IServicePagos" contract="ServiceReference1.IServicePagos" name="BasicHttpBinding_IServicePagos" />
    </client>
    <behaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
</configuration>

someone that tell me how y make this area chart with the list of my wcfservice please
David
Top achievements
Rank 1
 asked on 15 Nov 2012
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
Date/Time Pickers
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Application
Map
Drag and Drop
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
SPA
Filter
Drawing API
Drawer (Mobile)
Globalization
Gauges
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
MultiColumnComboBox
Chat
DateRangePicker
Dialog
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
OrgChart
TextBox
Effects
Accessibility
ScrollView
PivotGridV2
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Collapsible
Localization
MultiViewCalendar
Touch
Breadcrumb
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
Popover
DockManager
FloatingActionButton
TaskBoard
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
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?