Telerik Forums
Kendo UI for jQuery Forum
3 answers
111 views
kendo ui grid in editable mode  can't validate the input value when I cut the value from the textbox and then paste it into the  textbox again,and I find the demo for it  has the same problem,so I think my code is OK, it's a bug,who can help me to fix it???
Kiril Nikolov
Telerik team
 answered on 08 Jul 2013
1 answer
375 views
I have a treeview with databound to remote data from database. What I need is to set the image (icon) for the leaf nodes. The leaf nodes are of two different types; based on their type I need to set the icon before the text of the leaf node. I can easily set the image for parent nodes by setting the css for ".k-treeview .k-plus" and ".k-treeview .k-minus", but I do not know how to do it for leaf nodes based on their type.  I do not see any example of how to do that in the treeview demo either. It has one section that shows how to set the leaf node image, but the tree nodes are hard coded in the view with their image url hardcoded. I need something that has remote data binding and the treeview created dynamically. Any information on that will be highly appreciated. Thanks.
Iliana Dyankova
Telerik team
 answered on 08 Jul 2013
0 answers
34 views
01.<ul data-role="listview" data-type="group" id="itemListView" data-click="listViewClick" data-style="inset" class="km-listview km-listgroupinset">
02.  
03.    <li class="km-group-container words" itype="5" id="40f7eb7a426e40dbbc7ae1c3c8dc6988">
04.    <div class="km-group-title">
05.        <divclass="km-text itemTitle">Test 1</div>
06.    </div>
07.    <ul class="km-list">  
08.       <li class="checkboxlimit" cbl="1" ontouchend="touchEnd(event);"><label class="km-listview-label"><input type="checkbox" id="402881343face3ff013fad11f93a0026">B1</label></li>  
09.    </ul>
10.    </li>
11.      
12.      
13.    <li class="km-group-container words" itype="2" id="160265eecc6148c39a818913dcaf9870">
14.    <div class="km-group-title">
15.        <div class="km-text itemTitle">test2</div>
16.    </div>
17.    <ul class="km-list">   
18.        <li class="checkboxlimit"cbl="2"ontouchend="touchEnd(event);"><label class="km-listview-label"><input type="checkbox" id="402881343face3ff013fad11f7460021">A1</label></li
19.        <li class="checkboxlimit"cbl="2"ontouchend="touchEnd(event);"><label class="km-listview-label"><input type="checkbox" id="402881343face3ff013fad11f7940022">A2</label></li>  
20.        <li class="checkboxlimit"cbl="2"ontouchend="touchEnd(event);"><label class="km-listview-label"><input type="checkbox" id="402881343face3ff013fad11f7d20023">A3</label></li>
21.        <li class="checkboxlimit"cbl="2"ontouchend="touchEnd(event);"><label class="km-listview-label"><input type="checkbox" id="402881343face3ff013fad11f85e0024">A4</label></li>
22.    </ul>
23.    </li>
24.      
25.</ul>
there are two group of inputs , 
line 3 : test1 group 
line13: test2 group 
 the same code I test in v2012.3.1315 ,  everything is ok , but in this new version , when choose from the second group , check one itemfrom the second group , the first group's only one option can checked , but the one I choose in second group not checked correctly. for example , you can choose A3 or A4, repeatly for serval times , B1 will  be checked .
mociml
Top achievements
Rank 1
 asked on 08 Jul 2013
1 answer
924 views
Hello,

I am using Grids with the pageable option. I would like to keep the selected rows when the page is changed. The standard Grid behavior is, that the selection is not kept. But I already found an approach to store the row selection in the Change event and to restore it in the DataBound event.

global var:
    var selIdsAgentsInService = {};

In change event:
            // store selected rows of AgentsInService grid in selIdsAgentsInService array
            var ids = selIdsAgentsInService[gAgentsInService.dataSource.page()] = [];
            gAgentsInService.select().each(function () {
                dataItem = gAgentsInService.dataItem($(this));
                ids.push($(this).data().uid);
            });

In DataBound event:
        // restore selection
        var selected = $();
        var ids = selIdsAgentsInService[gAgentsInService.dataSource.page()] || [];
        for (var idx = 0, length = ids.length; idx < length; idx++) {
            selected = selected.add(gAgentsInService.table.find("tr[data-uid=" + ids[idx] + "]"));
            gAgentsInService.select(selected);
        }


This is still not exactly doing what I want, and therefore I am looking for a solution to handle the following use cases:

Use case 1 (which is working with my approach):
  1. a grid displays data spread over several pages
  2. rows are selected on page 1
  3. page is changed to another page without selecting any row and back to page 1
  4. the previously selected rows should still be selected
Use case 2:
  1. a grid displays data spread over several pages
  2. rows are selected on page 1
  3. page is changed to another page
  4. a single row is selected without pressing shift or ctrl
  5. page is changed back to page 1
  6. now the previously selected row from page on should be deselected
Use case 3:
  1. a grid displays data spread over several pages
  2. rows are selected on page 1
  3. page is changed to another page
  4. a single row is selected with pressing ctrl (to select an additional row)
  5. page is changed back to page 1
  6. now the previously selected row from page on should still be selected
Anyone having a solution for that? So I would like to support selecting additional rows by pressing ctrl and keeping the selection through all pages. Currently pressing or not pressing ctrl does not make difference in a Change event.

Regards
Sven
Dimo
Telerik team
 answered on 08 Jul 2013
2 answers
279 views
I have a combobox and a list view on a page. When ever an item is selected in the combo box it is suppose to load the listview with items from a table with the selected criteria. No matter what the data is not passed to the read method in the controller

The View
@(Html.Kendo().ComboBox()
        .Name("reportTablesCombo")
        .HtmlAttributes(userControlAttributes)                            
        .DataTextField("Text")
        .DataValueField("Value")                            
        .DataSource(source =>
        {
              source.Read(read =>
        {
                     read.Action("BuildSelectList", "ProgramManager", new { list = "Tables" });
        });
 })
       .Events(e =>
      {
             e.Change("Combo_onChange");
      })
 )     
@(Html.Kendo().ListView(Model)
      .Name("fieldListView")
       .ClientTemplateId("template")               
       .TagName("div")
       .Editable()
      .DataSource(dataSource =>{
                   dataSource.Model(model => model.Id("AdminFieldId"));
                    dataSource.Read(read => read.Action("_Read", "ProgramManager").Data("GetTable"));
                    dataSource.PageSize(10);   
        })
        .Pageable()  
 )
The javascipt

function Combo_onChange(e) {
 
       listdata.dataSource.read();
   }
 
   function GetTable() {
       debugger;
       var table = (reportTablesCombo != null  ? reportTablesCombo.text() : "");
       return table;
   }

the Read method in the controller. I have the debugger going and it returns the proper string but when it is read in the controller the value is ALWAYS null.

What am I doing wrong here?
public ActionResult _Read([DataSourceRequest]DataSourceRequest request, string table)
{
     var results = appDb.AdminFields.Where(t => t.AdminTableName == table);      
     return Json(results.ToDataSourceResult(request));
 }
Paul
Top achievements
Rank 1
 answered on 08 Jul 2013
6 answers
803 views

In MVC3 using VS 2010 I used this all the time no problem. You have an order. You want to be able to view the line items. So you click View in the Custom command of the data grid and it redirects you to a view with the line items for that order. I did this all the time with no issues

Problem: MVC4, VS 2012 and IE10.  Same type of thing. Click the button, it calls the Ajax which  calls the proper method in the controller and passes the parameter in but does not return the View.

I assume its a JQueary issue now. I have been pounding my head against the wall for a good day now and getting nowhere.


The View

@(Html.Kendo().Grid(Model).HtmlAttributes(gridAttributes)
    .Name("grid")
    .Columns(columns =>
    {
        columns.Command(command => { command.Edit().CancelText("Cancel"); command.Custom("Select").Click("showFields");}).Width(150);
        
        
        columns.Bound(c => c.TableName).Width(200);
        columns.Bound(c => c.FriendlyName).Width(200);
        columns.Bound(c => c.SecurityLevel).Width(125);
        columns.Bound(c => c.CanReportOn).Width(125).ClientTemplate("<input type='checkbox' #= CanReportOn ? checked='checked' : '' # value='#=AdminTableId#' class=\"check_row\"/>");
         
 
    })

The Ajax call
BTW, the preventDefault makes no difference. Same result

function showFields(e) {
       // e.preventDefault();
        var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
        var tableName = dataItem.TableName;
              
         
        $.ajax({
            url: '@Url.Action("ShowFields", "ProgramManager")',
             type: 'POST',
              data: { tableName: tableName }
          });
         
    }

The Controller method

public ActionResult ShowFields(string tableName)
{
          var list = appDb.AdminFields.Where(p => p.AdminTableName == tableName);           
          var model = new AdminFieldModel
          {
               Fields = list,
               TableName = tableName
           };
          return View(model);
}
Paul
Top achievements
Rank 1
 answered on 08 Jul 2013
1 answer
103 views
Hello Again =),

I have an issue, I am calculating some fields, and the first time when I load the page with the cache clean, it displays this calculated fields correctly, This is a DateTimePicker inside a Kendo Grid. So when the user click s it we want it to display in an specific format, but after the page has been reloaded or refresh or we go back to the same page,  the format of the date is not respected anymore. Do you have any ideas why is this issue created.

Here is my code"

//New WO to schedule grid
    workOrdersSchedulingDataSource = new kendo.data.DataSource({
        transport: {
            read: {
                // the remote service url
                url: '/sdata/api/dynamic/-/WorkOrders?where=(Status eq \'Unassigned\')&include=Customer,AssignedTo&count=200'
            }
        },
        type: 'sdata',
        serverSorting: true,
        sort: { field: "Priority", dir: "desc" },   
        schema: { data: "$resources",
            model: {
                fields: {$key: { editable: false, defaultValue: "00000000-0000-0000-0000-000000000000" },
                    Priority: { editable: false, nullable: true },
                    Customer: { editable: false, nullable: true },
                    LocationCity: { editable: false, nullable: true },
                    ServiceDate: { editable: true, nullable: true, type: "date" }, // This is the ones I care about
                    ServiceEndDate: { editable: true, nullable: true, type: "date" }, // This is the ones I care about
                    AssignedTo: { editable: true, nullable: true }
                }
            },
            parse: function (data) {
                $.each(data.$resources, function(idx, item) {
                    if (item.AssignedTo == null) {
                        item.AssignedTo = { $key: "", FirstName: "", LastName: ""} ;
                    }
                });
                return data;
            }
        },
        change: function () {
            var count = this.total();
            $("#workOrdersSchedulingCount").text(count);
            if (count == 0) {
                $("#zeroWorkOrdersToScheduling").removeClass("displayNone");
                $("#workOrdersSchedulingTable").addClass("displayNone");
                $("#workOrdersSchedulingFooter").addClass("displayNone");
            } else {
                $("#zeroWorkOrdersToScheduling").addClass("displayNone");
                $("#workOrdersSchedulingTable").removeClass("displayNone");
                $("#workOrdersSchedulingFooter").removeClass("displayNone");
                $("#unassignedBackground").removeClass("displayNone");
                $("#unassignedUnderline").removeClass("displayNone");
            }
        }
    });

var technicianDataSource = new kendo.data.DataSource({
        transport: {
            read: {
                url: "/sdata/api/dynamic/-/servicesuser?where=Role eq 'Technician'&include=user",
            }
        },
        type: 'sdata',
        schema: { data: "$resources",
            parse: function (data) {
                $.each(data.$resources, function(idx, item) {
                    item['FirstLastName'] = concatFirstLastName(item.User.FirstName, item.User.LastName);
                    item['Id'] = item.User.$key;
                    item['FirstName'] = item.User.FirstName;
                    item['LastName'] = item.User.LastName;
                    //This is the calculated field I cared about

                    item['ServiceDateCalc'] = $.dateUtilities.getUtcDate(item.ServiceDate);      
                    //This one too                          
                    item['ServiceEndDateCalc'] = $.dateUtilities.getUtcDate(item.ServiceEndDate);

                });
                return data;
            }
        }
    });

var schedulingGrid = $("#workOrdersSchedulingTable").kendoGrid({
        dataSource: workOrdersSchedulingDataSource,
        pageable: false,
        sortable: false,
        scrollable: true,
        height: 250,
        dataBound: function () {
            var grid = this;
            $.each(grid.tbody.find('tr'), function () {
                var model = grid.dataItem(this);
                //if Role equals NoRoleAssigned, attach star icon ahead of user name
                if (model.Priority === "Low") {
                    $('[data-uid=' + model.uid + ']' + '>td:first-child').prepend('<span class="staricon">&nbsp;<img src="/Content/images/lowPriority.png" />&nbsp;&nbsp;&nbsp;</span>');
                }
                else if (model.Priority === "Regular") {
                    $('[data-uid=' + model.uid + ']' + '>td:first-child').prepend('<span class="staricon">&nbsp;<img src="/Content/images/regularPriority.png" />&nbsp;&nbsp;&nbsp;</span>');
                }
                else {
                    $('[data-uid=' + model.uid + ']' + '>td:first-child').prepend('<span class="staricon">&nbsp;<img src="/Content/images/criticalPriority.png" />&nbsp;&nbsp;&nbsp;</span>');
                }
            });

            $("table tr").hover(
                function () {
                    $(this).toggleClass("k-state-hover");
                }
            );
        },
        columns: [
            { hidden: true, field: "$key", title: "Key", template: kendo.template($("#tempId").html()) },
            { field: "Priority", title: "Priority", width: "75px"},
            { field: "Customer", title: "Customer", width: "119px", template: "<div style='text-overflow: ellipsis; overflow: hidden; white-space: nowrap;' title='#= Customer.Name #'>#= Customer.Name # </div>"},
            { field: "LocationCity", title: "Location", width: "95px", template: "<div style='text-overflow: ellipsis; overflow: hidden; white-space: nowrap;' title='#= LocationCity #'>#= LocationCity?LocationCity:'N/A' # </div>" },
            { field: "ServiceDate", title: "Start", width: "155px", format: "{0:MM/dd/yyyy hh:mm tt}", template: kendo.template($("#tempStartDate").html()), editor: startDateTimeEditor },
            { field: "ServiceEndDate", title: "End", width: "155px", format: "{0:MM/dd/yyyy hh:mm tt}", template: kendo.template($("#tempEndDate").html()), editor: endDateTimeEditor },
            { field: "AssignedTo", title: "Technician", width: "145px", template: kendo.template($("#tempAssignedTo").html()), editor: assignedToDropDownEditor }
        ], editable: {
            template: null,
            createAt: "bottom"
        }
    });

    function startDateTimeEditor(container, options) {
        $('<input id="serviceDateEditor" data-bind="value:' + options.field + '"/>')
                .appendTo(container)
                .kendoDateTimePicker({
                    dataTextField: "ServiceDateCalc",
                    dataValueField: "ServiceDate"
                });
    }
    
    function endDateTimeEditor(container, options) {
        $('<input id="serviceEndDateEditor" data-bind="value:' + options.field + '"/>')
                .appendTo(container)
                .kendoDateTimePicker({
                    dataTextField: "ServiceEndDateCalc",
                    dataValueField: "ServiceEndDate"
                });
    }

So, it is working for the first time but after that the format gets messy.

Any suggestions? Thank you.

Guillermo Sanchez
Alexander Valchev
Telerik team
 answered on 08 Jul 2013
1 answer
121 views
Alex
Telerik team
 answered on 08 Jul 2013
7 answers
446 views
On change template in code, the repainting of the grid doesn't seem to expand and produce scrollbars to match the new height of the update grid display.

Here's an example. To reproduce the issue, click on the 'Change Template' button:
http://jsfiddle.net/65kWY/20/

PS. Setting scrollable to true (non-virtual) works just fine.

Vladimir Iliev
Telerik team
 answered on 08 Jul 2013
2 answers
87 views
Hello Community,

First of all I will like to thank Telerik for such a great product, it has been a very good experience developing my first Phonegap in conjunction with Keno UI Mobile, nice work ;)

Secondly, I have found a Bug with the state of buttons, to be more precise the class km-state-active gets stucked when a button is pressed, in navbar or content, so the user once have used a button from that view (back-button, actionsheet navbar button, button within content to open a link... and so on), will always get the button as pressed or with the  class km-state-active attached to it, resulting in a confusing and not so great user experience, and it also makes the App "less native" in a sense.

I have found a temporal solution, and will like to get a confirmation (if possible) from the telerik developing team, after trying to track a bit the matter from kendo.mobile.js, I have found that for some reason some of the new events (comparing events from build 2013.1.319) don't seem to work correctly, I will try to explain myself.

I have used an online javascript beautifier (don't know if links from other sites can be included here) and in line 6725 (this is based in the beautifier I have used, it may differ from your numeration) the function attached to the end it's not even triggering:
end: function (e) {
    t(r, e, !1)
}
What this causes is that the buttons can't listen to the end event and the class km-state-active keeps attached to the element causing this behaviour. 

My solution is to always attach this to the functions which are correctly called by the events, which are press and tap (I've done it in both just in case), which call the functions _activate and _release respectively, code from line 6719-6724 (I insist these are the lines I obtain after uncompressing Javascript with the online tool):
press: function (e) {
    r._activate(e)
},
tap: function (e) {
    r._release(e)
},
So I included at the end of the called functions what the end event was supposed to be doing, resulting in these modified versions, lines 6747-6765:
_activate: function (e) {
     var n = document.activeElement,
         i = n ? n.nodeName : "";
     t(this, e, !0), ("INPUT" == i || "TEXTAREA" == i) && n.blur()
     /*INSERT*/
     ;t(r, e, !1);
     /*INSERT*/
 
 },
 _release: function (t) {
     var n = this;
     t.which > 1 || n.trigger(c, {
         target: e(t.target),
         button: n.element
     }) && t.preventDefault()
     /*INSERT*/
     ;t(r, e, !1);
     /*INSERT*/
 },

After that I minify once more the whole javascript (including the Copyright licence on top once more obviously) and ready to go.

I don't know if this is the best approach but it did the trick for me, and it could also shed some light in tracking down this Bug from the last production version of Kendo UI Mobile (if it stills there of course...).

As I said before, thanks for the great product!
Cho-Lung
Top achievements
Rank 1
 answered on 08 Jul 2013
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?