Telerik Forums
Kendo UI for jQuery Forum
2 answers
270 views
Hi,

Loving Kendo so far! sure this is an easy one ...

I am creating a grouped list view with a switch in it as follows -

$("#listview").kendoMobileListView({
                dataSource: kendo.data.DataSource.create({ data: groupedData, group: "letter" }),
                template: '${name} <input checked="${live}" type="checkbox" data-role="switch" data-align="right" />',
                headerTemplate: "<h2>Letter ${value}</h2>"
});

This all loads fine, and I can set the checked state on load :)

BUT I want to access the created switches so I can bind to the change event and in turn store the users choice when they flick the switch?

Sadly, I am not sure how I can access the auto-generated template switch objects (or any object for that matter) for use in js?

Thanks
Matt
Matt
Top achievements
Rank 1
 answered on 05 Apr 2012
0 answers
134 views
I've got the following code that works well for initial load.  Once I execute .query I receive "Uncaught TypeError: Cannot read property '0' of undefined".  Kendo UI Mobile v2012.1.322

Am I using .query improperly?

Datasource/bind/sample data:

var ds = new kendo.data.DataSource({
  transport: {
    read: {
      url: "http://localhost:3000/api/anagram",
      dataType: "jsonp",
      data: {
        format: 'html',
        rack: '---'
      }
    }
  },
  group: 'length',
  pageSize: $('#pageSize').val(),
  page: $('#page').val(),
  sort: {field: 'word', dir: 'asc'},
  schema: {
    data: 'words',
    total: 'count',
    model: {
      fields: {
        length: {
          type: 'number'
        },
        word: {
          type: 'string'
        },
        wordFormat: {
          type: 'string'
        }
      }
    }
  }
  //serverFiltering: true,
  //filter: { field: 'rack', operator: 'eq', value: 'ab-' },
  //serverSorting: false,
});
 
function resultsBind() {
    console.log('Fetching...');
     
    ds.fetch(function(){
      console.log('Actually fetched');
      console.log(ds.total());
      console.log(ds.totalPages());
      $("#grouped-listview").kendoMobileListView({
          dataSource: ds,
          template: "#= wordFormat #",
          headerTemplate: "${value} Letters"
      });
      $('.prefix').html(ds.total() + ' words found');
    });
     
    $('#apply').click(function(){
      var p = $('#page').val();
      var ps = $('#pageSize').val();
      ds.query({ page: p, pageSize: ps });
    });
     
}
{"words":[{"length":3,"word":"azo","wordFormat":"<em>a</em>zo"},{"length":2,"word":"bo","wordFormat":"<em>b</em>o"},{"length":3,"word":"coz","wordFormat":"<em>c</em>oz"},{"length":2,"word":"do","wordFormat":"<em>d</em>o"},{"length":2,"word":"go","wordFormat":"<em>g</em>o"},{"length":2,"word":"ho","wordFormat":"<em>h</em>o"},{"length":2,"word":"jo","wordFormat":"<em>j</em>o"},{"length":2,"word":"lo","wordFormat":"<em>l</em>o"},{"length":2,"word":"mo","wordFormat":"<em>m</em>o"},{"length":2,"word":"no","wordFormat":"<em>n</em>o"},{"length":2,"word":"od","wordFormat":"o<em>d</em>"},{"length":2,"word":"oe","wordFormat":"o<em>e</em>"},{"length":2,"word":"of","wordFormat":"o<em>f</em>"},{"length":2,"word":"oh","wordFormat":"o<em>h</em>"},{"length":2,"word":"oi","wordFormat":"o<em>i</em>"},{"length":2,"word":"om","wordFormat":"o<em>m</em>"},{"length":2,"word":"on","wordFormat":"o<em>n</em>"},{"length":2,"word":"op","wordFormat":"o<em>p</em>"},{"length":2,"word":"or","wordFormat":"o<em>r</em>"},{"length":2,"word":"os","wordFormat":"o<em>s</em>"},{"length":2,"word":"ow","wordFormat":"o<em>w</em>"},{"length":2,"word":"ox","wordFormat":"o<em>x</em>"},{"length":2,"word":"oy","wordFormat":"o<em>y</em>"},{"length":2,"word":"so","wordFormat":"<em>s</em>o"},{"length":2,"word":"to","wordFormat":"<em>t</em>o"},{"length":2,"word":"wo","wordFormat":"<em>w</em>o"},{"length":2,"word":"yo","wordFormat":"<em>y</em>o"},{"length":2,"word":"za","wordFormat":"z<em>a</em>"},{"length":3,"word":"zoa","wordFormat":"zo<em>a</em>"},{"length":3,"word":"zoo","wordFormat":"zo<em>o</em>"}],"count":30,"input":"zo?"}
Ryan
Top achievements
Rank 1
 asked on 05 Apr 2012
1 answer
112 views
I have a grid that I want populated from a JSON callback. I also want pop-up editing. I see the callback occur to retrieve the data, but the grid isn't populated with it.

Here's a sample of the JSON result:
[{"AddedOn":"\/Date(1333241309627-0400)\/","Batch":"20120331-A","Comment":"Sample","User":"paulm"}]

I see the grid appear, and I get the button to add a new item (and the pop-up appears).
Secondary question: How do I control which fields are displayed in the pop-up? I don't see a list of options available for each field in the help (are they documented someplace?). 

$(function () {
    var dataSource = new kendo.data.DataSource({
        type: 'jsonp',
        transport: {
            read: {
                url: '/api/BatchApi/GetOpenBatchList',
                dataType: 'jsonp'
            },
            update: {
                url: '/api/BatchApi/Update',
                dataType: 'jsonp'
            },
            destroy: {
                url: '/api/BatchApi/Delete',
                dataType: 'jsonp'
            },
            create: {
                url: '/api/BatchApi/Create',
                dataType: 'jsonp'
            }
        },
        batch: true,
        pageSize: 30,
        schema: {
            model: {
                id: "Batch_ID",
                fields: {
                    Batch_ID: { editable: false, nullable: false },
                    Batch: { validation: { required: true} },
                    AddedOn: { type: "date", editable: false },
                    User: { editable: false },                       
                    Comment: { type: "string" }
                }
            }
        }
    });
 
    $("#batchGrid").kendoGrid({
        dataSource: dataSource,
        scrollable: true,
        sortable: true,
        selectable: 'row',
        toolbar: [{ name: 'create', text: 'New Batch'}],
        columns: [
                    { field: "Batch", title: "Batch" },
                    { field: "AddedOn", title: "Added On" },
                    { field: "User", title: "User" },
                    { command: ["edit"], title: " ", width: "100px" }
                 ],
        editable: "popup"
    });
});

The HTML is a basic div tag w/ID. <div id="batchGrid"></div>

I'm not seeing any JS errors. Just an empty grid. What am I missing?



PaulMrozowski
Top achievements
Rank 1
 answered on 05 Apr 2012
2 answers
186 views
Hi,

Can you please give me an example json response that a Java web server needs to send for this autocomplete code:

$(document).ready(function() {

var dataSource = new kendo.data.DataSource({
type: "jsonp",

transport: {

read: {

    url: "<c:url value="/Control?command=ko.sp_getCourses"/>"

}

}

});

$("#autoComplete").kendoAutoComplete({

  minLength: 3,

  dataTextField: "name", // JSON property name to use

  dataSource: dataSource

});

});


Thanks!
Ben
Top achievements
Rank 1
 answered on 05 Apr 2012
3 answers
1.3K+ views
Lan
Top achievements
Rank 1
 answered on 04 Apr 2012
0 answers
282 views
Hi,
I have been trying to adapt the script found at http://www.kendoui.com/forums/ui/treeview/breadcrumbs-to-selected-node.aspx to render a simple breadcrumb below the Kendo menu - not having any luck.  Anyone care to suggest a simple way to do this?

Additionally, I am trying to add the "k-state-selected" class to each parent item of the selected item in the menu.  I can style the current menu item as selected without problems, but I want to highlight all the parent nodes so each higher level is also styled as selected. 

I think the script needed to do the breadcrumbs could also be used to add the selected class to the parent nodes too...

Thoughts?
Richard
Top achievements
Rank 1
 asked on 04 Apr 2012
0 answers
117 views
Hi, somebody knows like using 2 combobox nested???

I have a grid with 2 combobox, and I need binding the second combobox to first combobox:

            $("#grid").kendoGrid({
                dataSource: DowsSharedDataSource,
                height: 400,
                autoSync: true,
                pageable: false,
                scrollable: false,
                navigatable: false,
                selectable: "row",
                sortable: false,
                change: onChange,
                editable: "popup",
                columns: [
                    {field: "CMFault_Desc", title: "Fault Desc" },
                    { field: "RT_Id1", editor: reasonComboEditor, title: "Reason 1" },
                    {field: "RT_Id2", editor: reasonComboEditor, title: "Reason 2" },
                    {command: ["edit"], title: " ", width: "190px" }
                ]
            });

            function reasonComboEditor(container, options) {
                $('<input name="' + options.field + '"/>').appendTo(container).kendoComboBox({
                    dataSource: ReasonTreeSharedDataSource,
                    dataValueField: "Id",
                    dataTextField: "Descr",
                    autobind: false
                });
            }

Tks.
Juan
Top achievements
Rank 1
 asked on 04 Apr 2012
1 answer
171 views
Hi, I have recently started working with Kendo and so far have been really impressed with it. The grid is quite robust and I am looking forward to obtaining a license and using the Kendo UI elements in my next project.

I have a couple of quick questions regarding the Kendio UI Grid (Web), which I was hoping someone could assist me with.

Firstly, I have been able to work with the columns pretty well so far and have been able to switch the datasource from a static html table to an array or json style data structure, which is a good step in the right direction.

For the project I am planning on using Kendo for, I need to basically display a list of contacts with the following requirements:

1) the table will be populated either by json or xml which will be output by a separate php script, this seems quite straightforward and I have done this with various libraries already so it is really just a matter of figuring out the syntax which I need to adhere to for the same protocol to work with Kendo's grid component.

2) a column containing inline action buttons must be added to the end of the table

3) a column containing checkboxes must be prepended to the table, this is basically to allow me to select multiple items. This must be able to be shown or hidden on command.


Now, I have accomplished all of the above when using a static HTML table before initializing it as a Kendo grid. However I am stumped so far in trying to accomplish the same when initializing the table using an empty div. I have tried creating a template and then setting the column's template to be equal to that, but this has resulted in either a) the html structure I put in place simply being output as a string in the column or b) the html I put in place is not being processed correctly, mainly in the case of the class names.

By the way here is an example of the code I have tried to use to set the actions template:

<script id="actions_tmpl" type="text/x-kendo-tmpl">
<div class="table_action chat_action"></div>
<div class="table_action mail_action"></div>
<div class="table_action edit_action"></div>
</script>

columns: [  { title: "", template: kendo.template($("#check_tmpl").html()) },
{ title: "Contact Name", field: "Name" },
{ title: "Company Name", field: "Company" },
{ title: "Phone", field: "Phone" },
{ title: "Email Address", field: "Email" },
{ title: "Address", field: "Address" },
{ title: "Actions", width: 78, template: kendo.template($("#actions_tmpl").html()) } ]

When you inspect the grid after it's initialization, the html exists, but the class names dont seem to come into effect for some reason?? Each div: .chat_action, .mail_action, .edit_action should display a small icon but this doesn't seem to be processed correctly as of yet.

One more issue that I am experiencing is the following, because I need to have the multiple select option implemented in the grid, there needs to be a top-level select all option but I haven't found a way so far to set the column header template or a way around that.

Any ideas would be hugely appreciated,
Thank you!
Conor
Top achievements
Rank 1
 answered on 04 Apr 2012
4 answers
408 views
I'm working on a data audit web applicaton which has a model containing several field sets composed of old value, new value, and current value fields. The current value is a calculated field (by KO terms) which uses fairly trivial logic to decide whether the old or new value should be used for the current value (basically if there is a new value then use it otherwise show the old value). There are about 20 of these field sets to be included in the overall form, and I'd like to avoid having to call `kendo.bind` for all of them individually.

Here's an example of what I'd like to be able to do (and the documentation sort of says should work, but doesn't):

<div id="practiceSection">
    <div id="phoneNumber">
        <h4>Phone Number</h4>
        <span>Display Value:</span>
        <input id="displayPhoneNumber" data-bind="value: phoneNumber.DisplayValue"/><br/>
        <span>Old Value:</span>
        <input id="oldPhoneNumber" data-bind="value: phoneNumber.OldValue"/><br/>
        <span>New Value:</span>
        <input id="newPhoneNumber" data-bind="value: phoneNumber.NewValue"/><br/>
    </div>
</div>​ 

String.IsNullOrEmpty function(value{
    var isNullOrEmpty true;
    if (value{
        if (typeof (value== 'string'{
            if (value.length 0)
                isNullOrEmpty false;
        }
    }
    return isNullOrEmpty;
}
    
function FieldBlock(oldValuenewValue{
    this.OldValue oldValue;
    this.NewValue newValue;

    this.DisplayValue function({
        var newValue this.get("NewValue");
        if (String.IsNullOrEmpty(newValue))
            return this.get("OldValue");
        
        return newValue;
    };
}
    
kendo.bind($("#practiceSection")kendo.observable({
    phoneNumbernew FieldBlock("111-111-1111"null
}));

jsfiddle

The code above results in `FieldBlock.DisplayValue` consistently returning undefined. Oddly enough, the dependent method does work if I pass the `FieldBlock` object to `kendo.observable` directly (not as the value of a property of an anonymous object). Here is a jsfiddle showing what does work but also what I'm trying to avoid.

Is this expected behavior? I'm using the 2012.01.322 build.

Also asked here to make sure I've avoided all of the typical non-ninja problems.
Atanas Korchev
Telerik team
 answered on 04 Apr 2012
2 answers
101 views
Hello,

I use remote views and I didn't succeed in debugging the js scripts that are loaded with these views. Did you know a way to debug the scripts of the remote views ?

Cordially,
Kakone.
Kakone
Top achievements
Rank 1
 answered on 04 Apr 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?