Telerik Forums
Kendo UI for jQuery Forum
1 answer
131 views
Hi,

Can anyone tell me how to retrieve the original object that was bound to the grid when a row is selected.
I attached the following callback to the "change" property of  grid.  I assume there is a way to fetch the original JSON object from this "arg" parameter.

function onChange(arg) {                
                .... Need to retrieve the object that was bound to the selected row.
                });

Thanks in advance.
Mohamed
Top achievements
Rank 1
 answered on 30 Mar 2012
1 answer
147 views
Do you have any plans for canvas based visualization components? 

Infragistics is demoing html5 canvas based charts with 500,000 data points where you can zoom in on specific points.  Just wondering if a similar story exists for SVG, performance wise does this translate?  Did you do any published analysis on this?

In the past, the recommended LOB path would have been a plugin (silverlight) to show this amount of data.  Now that this is available with a canvas it is tempting for LOB applications.

T. Tsonev
Telerik team
 answered on 30 Mar 2012
3 answers
1.4K+ views
Hello,

Before the new release, if i wanted to get the JSON object model in a data source, i did :
JSON.stringify(myGrid.dataSource.data());
But now, in the JSON string i have also a "_events" node inside it.

So, how can i get real data ?

Here the jsFiddle : http://jsfiddle.net/eyAkP/13/ 

Best Regards,
Guillaume


Valanto
Top achievements
Rank 1
 answered on 30 Mar 2012
8 answers
245 views
 I have the latest version of KendoComplete, and a grid that I have enabled grouping with a remote data source
I can group, but the arrow switch at the left of the group is missing, which means I cannot expand or
collapse the group. (this happens no matter what theme I choose).


I also have selectable enabled (by full row) with multiple items, and I would like to be able to press
the group heading and select the entire group at once. Any ideas?

                  $
("#grid").kendoGrid({
                        dataSource
: myRemoteData,
                        groupable
: true,
                        scrollable
: true,
                        sortable
: true,
                        pageable
: true,
selectable: "multiple, row",
...


Iliana Dyankova
Telerik team
 answered on 30 Mar 2012
1 answer
462 views
Hi,

I'm trying to get Server Aggregates working on my grid and I can't seem to get them to show up.  Server grouping, sorting, and filtering are all working until I return the aggregates and then the grid no longer renders the data.  

There seems to be an issue in writing the group footer.  I get the error on the call to that.groupFooterTemplate(group.aggregates) inside the grid's _groupRoiwHtml function: "Uncaught ReferenceError: sum is not defined".  I assume its either my groupFooterTemplate configuration or the actual aggregates I'm returning, but I can't figure it out.

Once I've got this working I'd also like to get the grid footer aggregates working, but I'm not sure where those are getting pulled from either. 

I've put some of the relevant configuration below:

DataSource.schema.model
{
   "fields": {
     "TestContacts_ID": {
       "editable": false,
       "nullable": true,
       "type": "string"
     },
     "TestContacts_CompanyName": {
       "editable": false,
       "nullable": true,
       "type": "string"
     }
   }
 }

DataSource.group
[
  {
    "field": "TestContacts_CompanyName",
    "dir": null,
    "aggregates": [
      {
        "field": "TestContacts_ID",
        "aggregate": "sum"
      }
    ]
  },
  {
    "field": "TestContacts_ID",
    "dir": null,
    "aggregates": [
      {
        "field": "TestContacts_ID",
        "aggregate": "sum"
      }
    ]
  }
]

DataSource.aggregate
[
  {
    "field": "TestContacts_ID",
    "aggregate": "sum"
  }
]

Grid.columns
[
   {
     "field": "TestContacts_ID",
     "title": "ID",
     "width": 75,
     "format": null,
     "template": null,
     "aggregates": [
       "sum"
     ],
     "groupHeaderTemplate": "ID: #= value #",
     "groupFooterTemplate": "Sum:#= sum #"
   },
   {
     "field": "TestContacts_CompanyName",
     "title": "CompanyName",
     "width": 200,
     "format": null,
     "template": null,
     "aggregates": null,
     "groupHeaderTemplate": "CompanyName: #= value #",
     "groupFooterTemplate": ""
   }
 ]

DataSource.schema.groups gets set to this:
[
    {
      "aggregates": {
        "TestContacts_ID": 78.0
      },
      "field": "TestContacts_CompanyName",
      "value": "MC 1",
      "hasSubgroups": true,
      "items": [
        {
          "aggregates": {
            "TestContacts_ID": 25.0
          },
          "field": "TestContacts_ID",
          "value": "25",
          "hasSubgroups": false,
          "items": [
            {
              "TestContacts_ID": "25",
              "TestContacts_CompanyName": "MC 1"
            }
          ]
        },
        {
          "aggregates": {
            "TestContacts_ID": 26.0
          },
          "field": "TestContacts_ID",
          "value": "26",
          "hasSubgroups": false,
          "items": [
            {
              "TestContacts_ID": "26",
              "TestContacts_CompanyName": "MC 1"
            }
          ]
        },
        {
          "aggregates": {
            "TestContacts_ID": 27.0
          },
          "field": "TestContacts_ID",
          "value": "27",
          "hasSubgroups": false,
          "items": [
            {
              "TestContacts_ID": "27",
              "TestContacts_CompanyName": "MC 1"
            }
          ]
        }
      ]
    },
    {
      "aggregates": {
        "TestContacts_ID": 57.0
      },
      "field": "TestContacts_CompanyName",
      "value": "MC 2",
      "hasSubgroups": true,
      "items": [
        {
          "aggregates": {
            "TestContacts_ID": 28.0
          },
          "field": "TestContacts_ID",
          "value": "28",
          "hasSubgroups": false,
          "items": [
            {
              "TestContacts_ID": "28",
              "TestContacts_CompanyName": "MC 2"
            }
          ]
        },
        {
          "aggregates": {
            "TestContacts_ID": 29.0
          },
          "field": "TestContacts_ID",
          "value": "29",
          "hasSubgroups": false,
          "items": [
            {
              "TestContacts_ID": "29",
              "TestContacts_CompanyName": "MC 2"
            }
          ]
        }
      ]
    }
  ]

Also, it would be awesome to have a sample out there that showed how to implement server-side everything (sort,filter,group,aggregates) so one could get an idea what the setup would look like...

Thanks!
Matt
Rosen
Telerik team
 answered on 30 Mar 2012
1 answer
226 views
Hi
i tries to use popup editing using the asp.net examples https://github.com/telerik/kendo-examples-asp-net

by changing the editor option to "popup" but it does not response and continue use inline editing

and also when i try to create new on using the below code it doesn't work


script code  
$(document).ready(function () {
 
 
 
    $("#mygrid").kendoGrid({
        dataSource: {
            schema: {
                data: 'd',
                model: {
                    id: "Id",
                    fields: {
                        Id: { type: "number" },
                        FirstName: { type: "string" },
                        LastName: { type: "string" },
                        City: { type: "string" },
                        BirthDate: { type: "date" }
                    }
                }
            },
            transport: {
                create: {
                    url: "../Webservices/KendoService.asmx/CreateAds", //specify the URL which should create new records. This is the Create method of the Products.asmx service.
                    contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
                    type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
                },
                read: {
                    url: "../Webservices/KendoService.asmx/ReadAds", //specify the URL which data should return the records. This is the Read method of the Products.asmx service.
                    contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
                    type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
                },
                update: {
                    url: "../Webservices/KendoService.asmx/UpdateAds", //specify the URL from which should update the records. This is the Update method of the Products.asmx service.
                    contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
                    type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
                },
                destroy: {
                    url: "../Webservices/KendoService.asmx/DestroyAds", //specify the URL which should destroy records. This is the Destroy method of the Products.asmx service.
                    contentType: "application/json; charset=utf-8", // tells the web service to serialize JSON
                    type: "POST" //use HTTP POST request as the default GET is not allowed for ASMX
                },
                parameterMap: function (data, operation) {
                    if (operation != "read") {
                        // web service method parameters need to be send as JSON. The Create, Update and Destroy methods have a "products" parameter.
                        return JSON.stringify({ products: data.models })
                    }
                }
            },
            pageSize: 10
        },
        pageable: true,
        height: 400,
        toolbar: ["create"],
        columns: [
        { field: "Id", width: "60px" },
        { field: "FirstName", title: "First Name" },
        { field: "LastName", title: "Last Name" },
        { field: "City" },
        { field: "BirthDate", template: '#= kendo.toString(BirthDate,"MM/dd/yyyy") #' },
        { command: [
                { name: "edit", text: "CustomEdit" }, // sets the text of the Edit button
                {name: "destroy", text: "Destroy"} // sets the text of the "Delete" button
            ],
            // sets the title and the width of the commands column
            title: " ",
            width: "300px"
        }
    ],
        editable: "popup",
        //changes the text of the "Update" and "Cancel" buttons in the inline edit mode
        edit: function () {
            var updateBtnTxt = "CustomUpdate",
            cancelBtnTxt = "CustomCancel",
            curr_container = this._editContainer; //selects the current edit container
 
            //sets the text of the "Update" button
            $(curr_container).find("a.k-grid-update").text(updateBtnTxt);
            //sets the text of the "Cancel" button
            $(curr_container).find("a.k-grid-cancel").text(cancelBtnTxt);
        }
    });
 
 
});

web service code

    /// <summary>
    /// Creates new products by inserting the data posted by the Kendo Grid in the database.
    /// </summary>
    /// <param name="products">The products created by the user.</param>
    /// <returns>The inserted products so the Kendo Grid is aware of the database generated ProductID</returns>
    [WebMethod]
    public IEnumerable<TempJson> CreateAds(IEnumerable<TempJson> products)
    {
        var result = new List<JobHistory>();
 
        JobHistoryDB sdb = new JobHistoryDB();
        JobHistoryCollection myCollection = new JobHistoryCollection();
        List<TempJson> returned = new List<TempJson>();
        foreach (TempJson j in products)
        {
            JobHistory my = new JobHistory();
            my.Approved = true;
            my.CompanyID = 1;
            my.CompanyName = "";
            my.End = DateTime.Parse(j.BirthDate);
            my.Start = DateTime.Parse(j.BirthDate);
            my.JobTitle = j.FirstName;
 
            myCollection.Add(my);
        }
 
        sdb.Insert(myCollection);
        if (sdb.Insert(myCollection) > 0)
        {
 
            foreach (JobHistory j in myCollection)
            {
                TempJson mj = new TempJson();
                mj.Id = j.JobHistoryID;
                mj.FirstName = j.JobTitle;
                mj.LastName = j.CompanyName;
                mj.BirthDate = j.Start.ToShortDateString();
 
                returned.Add(mj);
            }
        }
        return returned;
 
 
    }
 
    /// <summary>
    /// Reads the available products to provide data for the Kendo Grid
    /// </summary>
    /// <returns>All available products</returns>
    [WebMethod]
    public IEnumerable<TempJson> ReadAds()
    {
 
        JobHistoryDB sdb = new JobHistoryDB();
        JobHistoryCollection myCollection = new JobHistoryCollection();
        List<TempJson> returned = new List<TempJson>();
        foreach (JobHistory j in sdb.GetAll())
        {
            TempJson mj = new TempJson();
            mj.Id = j.JobHistoryID;
            mj.FirstName = j.JobTitle;
            mj.LastName = j.CompanyName;
            mj.BirthDate = j.Start.ToShortDateString();
 
            returned.Add(mj);
        }
        return returned;
 
    }
 
    /// <summary>
    /// Updates existing products by updating the database with the data posted by the Kendo Grid.
    /// </summary>
    /// <param name="products">The products updated by the user</param>
    [WebMethod]
    public void UpdateAds(IEnumerable<TempJson> products)
    {
 
        JobHistoryDB sdb = new JobHistoryDB();
        JobHistoryCollection myCollection = new JobHistoryCollection();
 
        foreach (TempJson j in products)
        {
            JobHistory my = sdb.GetByPK_JobHistory(j.Id)[0];
            my.End = DateTime.Parse(j.BirthDate);
            my.JobTitle = j.FirstName;
            myCollection.Add(my);
        }
 
 
 
        sdb.Update(myCollection);
 
    }
 
    /// <summary>
    /// Destroys existing products by deleting them from the database.
    /// </summary>
    /// <param name="products">The products deleted by the user</param>
    [WebMethod]
    public void DestroyAds(IEnumerable<TempJson> products)
    {
        JobHistoryDB sdb = new JobHistoryDB();
        JobHistoryCollection myCollection = new JobHistoryCollection();
 
        foreach (TempJson j in products)
        {
            JobHistory my = sdb.GetByPK_JobHistory(j.Id)[0];
 
            myCollection.Add(my);
        }
 
 
 
        sdb.Delete(myCollection);
    }
 
     
}
 
public class TempJson
{
    public int Id { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
    public string City { get; set; }
    public string BirthDate { get; set; }
}

thanks
Alexander Valchev
Telerik team
 answered on 30 Mar 2012
1 answer
197 views
I have a Kendo Grid bound to a Wcf service that follows the example found in https://github.com/telerik/kendo-examples-asp-net/tree/master/grid-wcf-crud 

This sample is based on a Wcf using <enableWebScript />.  My service's Update receives the DTO from Kendo Datasource and updates perfectly, returning {"d":null}, exactly as does the grid-wcf-crud project's Product.cs Update service method.

Back in the browser, the in IE9, an error is experienced in kendo.web.js:
  Line: 5128
  Error: Unable to get value of the property 'length': object is null or undefined

it is likely happening in the code that is seeking to mark the rows as not dirty, because they are included in the next Save invocation, and are still marked with a red tic mark.

This error does not happen in Chrome.  This error does not happen in IE  when running the grid-wcf-crud.  I cannot find any difference between my implementation and the sample.  web.config is virtually the same between my app having the error compared to the grid-wcf-crud sample that does not have the error.  Any ideas?

The code in kendo.web.js that is hitting the error follows, with the error on the last line where data is null in " length = data.length ":

    var DataReader = Class.extend({
        init: function(schema) {
            var that = this, member, get, model;
            schema = schema || {};
            for (member in schema) {
                get = schema[member];
                that[member] = typeof get === STRING ? getter(get) : get;
            }
            if (isPlainObject(that.model)) {
                that.model = model = kendo.data.Model.define(that.model);
                var dataFunction = that.data,
                getters = {};
                if (model.fields) {
                    each(model.fields, function(field, value) {
                        if (isPlainObject(value) && value.field) {
                            getters[value.field] = getter(value.field);
                        } else {
                            getters[field] = getter(field);
                        }
                    });
                }
                that.data = function(data) {
                    var record,
                        getter,
                        idx,
                        length,
                        modelInstance = new that.model();
                    data = dataFunction(data);
                    if (!isEmptyObject(getters)) {
                        for (idx = 0, length = data.length; ...........
Daniel
Telerik team
 answered on 30 Mar 2012
5 answers
284 views
I am popping up a window and the opening and closing works fine, but the content while simple isn't all rendered. The DIV for the window is below. I have an ordered list with four items and 4 input buttons.

The ordered list, seems to be converted to paragraphs and the input buttons are just plain text. The H1 and the SPAN work as expected. Inspecting them in Firebug, shows that they have the UL, LI tags. The behavor is the same in IE9, Firefox, Chrome and Opera.

Thanks
Randy

<div id="winAutoSave" data-role="window">
    <h1>Auto Saved Application</h1>
    <p>An auto saved application has been found. <span style=" font-weight: bold; font-style:italic; color: Red;">Sample Red Text</span> This probably occured if you broswer hung or was closed without saving. At this point you may either</p>
    <ol>
        <li>Option 1</li>
        <li>Option 2</li>
        <li>Option 3</li>
        <li>Option 4</li>
    </ol>
    <div style=" text-align: center; margin-top: 10px; padding-left: 35px;">
        <input type="button" value="Option 1" />
        <input type="button" value="Option 2" />
        <input type="button" value="Option 3" />
        <input type="button" value="Option 4" />
    </div>
    <div class="clearAll"></div>
</div>
Kamen Bundev
Telerik team
 answered on 30 Mar 2012
1 answer
98 views
I have a Grid binded to a DataSource.
I handle the DataSource Error event this way:

error: function (e) {
    alert(e);
    _ds.cancelChanges();
}

I try to delete a row that throws an Exception. The first time, it's ok ; I see the error and the row is back again.
If I try to delete the same row again, I see in Firebug that 2 requests are made, for the same Id.
It I try to delete the same row again, 3 requests are made. etc. etc.

What am I doing wrong ?
Rosen
Telerik team
 answered on 30 Mar 2012
1 answer
78 views
jQuery Mobile supports posting <form> tags automatically using AJAX:
http://jquerymobile.com/test/docs/forms/docs-forms.html 

Does Kendo UI Mobile support this? I can't find any documentation/examples. Do we have to implement our own AJAX methods for each form?
Petyo
Telerik team
 answered on 30 Mar 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?