Telerik Forums
Kendo UI for jQuery Forum
1 answer
501 views
http://jsfiddle.net/RichardAD/BemTb/ demonstrates how .preventDefault() can be used to prevent normal selection, and thus allow multiple selections and node deselection.
Coy
Top achievements
Rank 1
 answered on 14 May 2014
2 answers
379 views
Hi ,

I am trying to set the Tool tip for Kendo Create button on the grid toolbar.

Can any one help me in setting it up on writer grid and agent grid.

This is how I am setting up the Add new record button in toolbar. --> { name: "create", text: "" }, in the demo below.

Thanks
Chatrapathi Chennam

Chatra
Top achievements
Rank 1
 answered on 13 May 2014
1 answer
521 views
I have a Kendo UI MVC control on my asp.net MVC page, i want to highlight specific dates based on information from my database. EG on 9/Aug/2012 there were 7 appointments raised.


I'd like to use the custom template like this 


    <%= Html.Kendo().Calendar()
            .Name("calendar")
            .Value(DateTime.Today)
            .HtmlAttributes(new { style = "width:330px" })
            .Footer("Today - #=kendo.toString(data, 'd') #")
                .MonthTemplate("# if ($.inArray(+data.date, events) != -1) { #" +
                                "'<div class=\"" +
                                "# if (data.value < 10) { #" +
                                        "exhibition" +
                                    "# } else if ( data.value < 20 ) { #" +
                                        "party" +
                                    "# } else { #" +
                                        "cocktail" +
                                    "# } #" +
                                "\"></div>" +
                            "# } #" +
                            "#= data.value #")                     
    %>
    
    <script>
        var today = new Date(),
            events = [
                +new Date(today.getFullYear(), today.getMonth(), 8),
                +new Date(today.getFullYear(), today.getMonth(), 12),
                +new Date(today.getFullYear(), today.getMonth(), 24),
                +new Date(today.getFullYear(), today.getMonth() + 1, 6),
                +new Date(today.getFullYear(), today.getMonth() + 1, 7),
                +new Date(today.getFullYear(), today.getMonth() + 1, 25),
                +new Date(today.getFullYear(), today.getMonth() + 1, 27),
                +new Date(today.getFullYear(), today.getMonth() - 1, 3),
                +new Date(today.getFullYear(), today.getMonth() - 1, 5),
                +new Date(today.getFullYear(), today.getMonth() - 2, 22),
                +new Date(today.getFullYear(), today.getMonth() - 2, 27)
            ];
    </script>


How can I replace the above javascript array with an array on my viewmodel?
Something like this - 


    .MonthTemplate("# if ($.inArray(+data.date, " + Model.Array + ") != -1) { #" +
                                    "'<div class=\"" +
                                    "# if (data.value < 10) { #" +
                                            "exhibition" +
                                        "# } else if ( data.value < 20 ) { #" +
                                            "party" +
                                        "# } else { #" +
                                            "cocktail" +
                                        "# } #" +
                                    "\"></div>" +
                                "# } #" +
                                "#= data.value #")                     
        %>


Thanks

Jarrod
Top achievements
Rank 1
 answered on 13 May 2014
2 answers
143 views
Hello,

I am trying to make this grid using Json. The filters for Country code and Company codes are not working. I have attached the screenshot of the grid (grid value is not provided for security of data). As you can understand form the code snippet that "userConstraints" field is an object which later split into two columns Country Code and Company Code and where the filters are not working. I would like to make it work in client side. Do not prefer to solve it in sever side. Please let me know if i missed anything. Thanks in advance!

Screen Shot:


Json Data for Field "userConstraints"


Code Snippet:

getUsers: function (data, response) {
        permissionManagementViewModel.SubjectRoleMapping(response);
        $('#RolesGrid').html();
        $('#RolesGrid').kendoGrid({
            dataSource: {
                data: response,
                batch: false,
                pageSize: 10,
                schema: {
                    model: {
                        fields: {
                            AccountName: { editable: false },
                            RoleName: { editable: false },
                            ConstraintsExpression: { editable: false },
                            userConstraints: { editable: false },
                            Status: { editable: false }
                        }
                    }, parse: function (data) {
                        $.each(data, function (i, val) {
                        });
                        return data;
                    }
                }
            },
            editable: true,
            filterable: {
                extra: true, //do not show extra filters
                operators: { // redefine the string operators
                    string: {
                        contains: "Contains",
                        startswith: "Starts With",
                        eq: "Is Equal To",
                        doesnotcontain: "Does not contain",
                        endswith: "Ends with",
                        neq: "Is not equal to"
                    }
                }
            },
            pageable: true,
            scrollable: true,
            resizable: true,
            sortable: true,
            selectable: true,
            resizable: true,
            columns: [
                { field: "AccountName", title: "User Name", width: '150px' },
                { field: "RoleName", title: "Role Name", width: '150px' },
                { field: "Status", hidden: true },
                { field: "userConstraints", template: "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px' title='#=stringifyCountryValues(userConstraints, Status, 'Subject_CountryCode')#'>#= stringifyCountryValues(userConstraints, Status, 'Subject_CountryCode') #</span>", title: "Country Codes", width: '100px' },
                { field: "userConstraints", template: "<span style='overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100px' title='#=stringifyCountryValues(userConstraints, Status, 'Subject_CompanyCode')#'>#= stringifyCountryValues(userConstraints, Status, 'Subject_CompanyCode') #</span>", title: "Company Codes", width: '100px' },
                { field: "", title: "View/Edit", width: '80px', template: "<input class='btnViewPermissions' type='button' value='View/Edit' onclick='javascript:permissionManagementViewModel.ViewUser(\"#=encodeURIComponent(AccountName)#\", \"#=RoleName#\", \"#=Status#\")'  />" },
                { field: "", title: "Delete", width: '80px', template: "<input class='btnDeletePermissions' type='button'  value='Delete' onclick='javascript:permissionManagementViewModel.DeleteUser(\"#=encodeURIComponent(AccountName)#\", \"#=RoleName#\")'  />" }
            ]
        })
        var grid = $("#RolesGrid").data("kendoGrid");
        grid.bind("dataBound", onpermissionsDataBound);
        grid.dataSource.fetch();
        permissionManagementViewModel.Action('');
    },
Rosen
Telerik team
 answered on 13 May 2014
3 answers
201 views
I am trying to read the Entity1 using the dataSource schema from the returned json object.


The Json Object is as follow
{
"odata.metadata":"http://localhost:25061/odata/$metadata#Entity,"value":[
{
"Entity1":{
"LastName":"Smith","FirstName":"James"},"Id":1,"Other":2},{
"Entity1":{
"LastName":"Smith","FirstName":"Alex"},"Id":2,"Other":3}
}]
}Datasource Schema
schema: {
data: function (data) { return data.value; },
total: function (data) { return data["odata.count"]; },
},Model
$("#grid").kendoGrid({
dataSource: dataSource,
filterable: true,
sortable: true,
pageable: true,
columns: [
{ field: "LastName" },
{ field: "FirstName" }
]
});Thanks,
DG
Kiril Nikolov
Telerik team
 answered on 13 May 2014
1 answer
555 views
Hi guys, I'm new to Kendo and am struggling to understand why the change and error event handlers defined in my datasource are not called. I have a grid with popup edit functionality. I would like to display a notification when a record has create, update or delete operations performed on it. Any advice is appreciated.
<div id="grid" style="margin-bottom: 20px"></div>
<!-- Data sources for supporter and supportee AutoComplete. -->
<script type="text/javascript">
  var supporterDataSource = new kendo.data.DataSource({
    transport: {
      read: {
        url: "<%= supporters_admin_customer_support_clients_url + '.json' %>",
        dataType: 'json',
        error: function (xhr) {
          var errors = $.parseJSON(xhr.responseText).errors;
          popupNotification.show(errors);
        }
      },
      schema: {
        user_id: { type: 'number' },
        full_name: { type: 'string' }
      }
    }
  });
  var supporteeDataSource = new kendo.data.DataSource({
    transport: {
      read: {
        url: "<%= supportees_admin_customer_support_clients_url + '.json' %>",
        dataType: 'json',
        error: function (xhr) {
          var errors = $.parseJSON(xhr.responseText).errors;
          popupNotification.show(errors);
        }
      },
      schema: {
        user_id: { type: 'number' },
        full_name: { type: 'string' }
      }
    }
  });
</script>
<!-- Tooltip error template for validation -->
<script id="tooltip-template" type="text/x-kendo-template">
  <span class="k-widget k-tooltip k-tooltip-validation k-invalid-msg">
    <span class="k-icon k-warning"></span>
    #=message#
  </span>
</script>
<!-- Popup editor template for customer support client grid -->
<script id="popup_editor" type="text/x-kendo-template">
  <div id="popServerErrorSummaryPlaceholder" style="display:none"></div>
  <div class="k-edit-label" style="padding-right: 10px">
    <label for="Customer Support Rep">Customer Support Rep</label>
  </div>
  <input name="Customer Support Rep"
     data-bind="value:supporter_name"
     data-value-field="user_id"
     data-text-field="full_name"
     data-source="supporterDataSource"
     data-role="autocomplete"
     required>
  <input type="hidden" name="SupporterID" data-bind="value:supporter_id">
  <div class="clear"></div>
  <div class="k-edit-label" style="padding-right: 10px">
    <label for="Researcher">Researcher</label>
  </div>
  <input name="Researcher"
     data-bind="value:supportee_name"
     data-value-field="user_id"
     data-text-field="full_name"
     data-source="supporteeDataSource"
     data-role="autocomplete"
     required>
  <input type="hidden" name="SupporteeID" data-bind="value:supportee_id">
</script>
<!-- Customer support client grid -->
<% content_for :javascript do %>
  var crudServiceBaseUrl = "<%= admin_customer_support_clients_url %>",
    dataSource = new kendo.data.DataSource({
      transport: {
        read: {
          url: crudServiceBaseUrl + '.json',
          dataType: 'json',
          error: function (xhr) {
            var errors = $.parseJSON(xhr.responseText).errors;
            popupNotification.show(errors);
          }
        },
        create: {
          url: crudServiceBaseUrl + '.json',
          type: "POST",
          dataType: 'json',
          change: function(data) {
            popupNotification.show('Customer support client created successfully');
          },
          error: function (xhr) {
            var errors = $.parseJSON(xhr.responseText).errors;
            popupNotification.show(errors);
          }
        },
        update: {
          url: function (data) {
            return crudServiceBaseUrl + '/' + data.id + '.json';
          },
          type: 'PATCH',
          dataType: 'json',
          change: function (data) {
            popupNotification.show('Customer support client updated successfully');
          },
          error: function (xhr) {
            var errors = $.parseJSON(xhr.responseText).errors;
            popupNotification.show(errors);
          }
        },
        destroy: {
          url: function (data) {
            return crudServiceBaseUrl + '/' + data.id + '.json';
          },
          type: 'DELETE',
          dataType: 'json',
          change: function (data) {
            popupNotification.show('Customer support client deleted successfully');
          },
          error: function (xhr) {
            var errors = $.parseJSON(xhr.responseText).errors;
            popupNotification.show(errors);
          }
        },
        parameterMap: function(options, operation) {
          if (operation !== 'read') {
            return {customer_support_client: kendo.stringify(options)};
          }
        }
      },
      pageSize: 20,
      serverPaging: false,
      serverFiltering: false,
      serverSorting: false,
      schema: {
        model: {
          id: 'id',
          fields: {
            id: {editable: false, nullable: true, type: 'number'},
            supporter_id: {type: 'number'},
            supporter_name: {type: 'string'},
            supportee_id: {type: 'number'},
            supportee_name: {type: 'string'},
            created_at: {editable: false, type: 'date'},
            updated_at: {editable: false, type: 'date'}
          }
        }
      }
    });
 
  $('#grid').kendoGrid({
    dataSource: dataSource,
    editable: {
      mode: 'popup',
      template: kendo.template($('#popup_editor').html())
    },
    edit: function(e) {
      $(e.container)
        .find('input[name="Customer Support Rep"]')
        .data('kendoAutoComplete')
        .bind('change', function(e) {})
        .bind('select', function(e) {
          var csc = this.dataItem(e.item.index());
          // Note .change is required to update underlying data source.
          $('input[name="SupporterID"]').val(csc.user_id).change();
        });
      $(e.container)
        .find('input[name="Researcher"]')
        .data('kendoAutoComplete')
        .bind('change', function(e) {})
        .bind('select', function(e) {
          var csc = this.dataItem(e.item.index());
          // Note .change is required to update underlying data source.
          $('input[name="SupporteeID"]').val(csc.user_id).change();
        });
      e.sender.editable.validatable._errorTemplate = kendo.template($('#tooltip-template').html());
      // TODO - Chrome Hack - Remove this when jQuery is v1.8 or above.
      $('.k-widget.k-window').css('webkit-transform', 'scale(1)');
    },
    toolbar: ['create'],
    height: 500,
    filterable: true,
    sortable: true,
    pageable: true,
    columns: [{
      field: 'supporter_name',
      title: 'Customer Support Rep',
      type: 'string'
    }, {
      field: 'supportee_name',
      title: 'Researcher',
      type: 'string'
    }, {
      field: 'created_at',
      title: 'Created At',
      type: 'date',
      format: '{0:dd-MMM-yyyy hh:mm tt}',
      parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]
    }, {
      field: 'updated_at',
      title: 'Updated At',
      type: 'date',
      format: '{0:dd-MMM-yyyy hh:mm tt}',
      parseFormats: ["yyyy-MM-dd'T'HH:mm:ss.zz"]
    }, {
      command: ['edit', 'destroy'],
      title: ' ',
      width: '175px'
    }]
  });
 
  var popupNotification = $("#popupNotification").kendoNotification().data("kendoNotification");
<% end %>


Rosen
Telerik team
 answered on 13 May 2014
3 answers
183 views
Hello
For a project I have a strong requirement to manage authenticated users either using a CAS (Central Authentication Service) or as a second option a LDAP authenitcation
Is it something available when developping witthin Kendo UI?

Something else I will need to implement, changing CSS styles on the fly. In other words to be able to download a new CSS style file and change it on the fly?

Should it be easy to develop an app with Kendo UI, managing several languages languages?

many thanks by advance

BR


Anton Dobrev
Telerik team
 answered on 13 May 2014
1 answer
687 views
After releasing our first Kendo web app to the public we received a lot of feedback about the listview scrolling having a very bad performance. Some users on older smartphones weren't able to scroll down in an appropriate way at all.

So we decided to switch to native scrolling following this documentation: http://docs.telerik.com/kendo-ui/getting-started/mobile/native-scrolling

Instead of

new kendo.mobile.Application(document.body, { useNativeScrolling: true });

which completely screwed our whole app, we used data-use-native-scrolling="true" for the views.

After the change, scrolling was very performant, but we encountered a strange behaviour of the listviews regarding setting back the scroll position. We tried several ways of resetting the listviews scroll position:

1. via e.view.scroller inside the show() event

The documentation mentioned above states that there is no scroller object when using native scrolling, but in fact there is. So we used e.view.scroller.scrollTo(0, 0) at the end of the show() event.

Problems: several users reported that clicks on listview items were not correctly processed, instead a different listview items click event was executed, leading to the wrong details page.

2. via window.scrollTo(0,0) (as recommended in the documentation)

Problems: when going back using the phones back button, the listview jumps to the top before switching the view. Looks really awkward. Also, the listviews scrolling position is often not set back, it stays scrolled.

3. no scrollTo() at all

Problems: same as 2.


So I have 2 questions:

1. What would be the correct way to handle a view with a listview using native scrolling?

2. Is the abysmal scrolling performance with listviews normal? Even on the newest quad core devices we noticed a huge performance difference to native scrolling. Is there a way to optimize that?

Thanks in advance for any hint on this,
Roman
Petyo
Telerik team
 answered on 13 May 2014
5 answers
641 views
I have read how you can add a dependent method / calculated field to an ObservableObject (http://docs.kendoui.com/getting-started/framework/mvvm/observableobject), but I cannot find how you can define a dependent method / calculated field in the schema of a Model (http://docs.kendoui.com/api/framework/model). The instances of my Model are read from a remote kendo DataSource, so I need to define a dependent method / calculated field in the schema of the Model so that every instance of my Model automatically has this dependent method / calculated field. I've tried defining it as a field with the defaultValue set to the function and set nullable: true, but all the instances of my Model end up with null values in this field. Here's an example:

var Category = kendo.data.Model.define({
    id: "Id",
    fields: {
        Id: { type: "number", editable: false, nullable: true},
        Title: { type: "string" },
        SortOrder: { type: "number" }
    }
}
 
var Product = kendo.data.Model.define({
    id: "Id",
    fields: {
        Id: { type: "number", editable: false, nullable: true},
        Title: { type: "string" },
        CategoryId: { type: "number" },
        Category: {},
        CategorySortOrder: { defaultValue: function() { return this.get("Category.SortOrder"); }, nullable: true
    }
}

so when I get an instance of my Product from my kendo DataSource its CategorySortOrder property is null. So, how to define dependent method / calculated field in model schema?
Alexander Valchev
Telerik team
 answered on 13 May 2014
3 answers
424 views
I am sure this is a dumb question but I have not been succesful in finding the answer.  How do I get the value of a querystring example below im trying to get the querystring value from querystring parameter named ID and set it in the data part of my datasource.  my data source works hard coded.

var

 

 

dsDetails = new kendo.data.DataSource({

group: { field:

 

"_Title", dir: "asc" },

transport: {

read: {

url:

 

"../api/EventDetails",

dataType:

 

"json",

data: {

ID:

 

"4dc2fa9a-fb45-4ff5-b6d8-c246dbd3024e";

}

}

}

},

schema: {

model: {

fields: {

_ID: { type:

 

"string" },

_BeginDate: { type:

 

"string" },

_Cost: { type:

 

"string" },

_EndDate: { type:

 

"string" },

_EndTime: { type:

 

"string" },

_EventType: { type:

 

"string" },

_StartTime: { type:

 

"string" },

_SupportedBy: { type:

 

"string" },

_Title: { type:

 

"string" }

}

}

},

});

ds.read();

Mike
Top achievements
Rank 1
 answered on 13 May 2014
Narrow your results
Selected tags
Tags
Grid
General Discussions
Charts
Data Source
Scheduler
DropDownList
TreeView
MVVM
Editor
Window
DatePicker
Spreadsheet
Upload
ListView (Mobile)
ComboBox
TabStrip
MultiSelect
AutoComplete
ListView
Menu
Templates
Gantt
Validation
TreeList
Diagram
NumericTextBox
Splitter
PanelBar
Drag and Drop
Application
Map
ToolTip
Calendar
PivotGrid
ScrollView (Mobile)
Toolbar
TabStrip (Mobile)
Slider
Button (Mobile)
Filter
SPA
Drawing API
Drawer (Mobile)
Globalization
LinearGauge
Sortable
ModalView
Hierarchical Data Source
Button
FileManager
MaskedTextBox
View
Form
NavBar
Notification
Switch (Mobile)
SplitView
DropDownTree
ListBox
PDFViewer
Sparkline
ActionSheet
TileLayout
PopOver (Mobile)
TreeMap
ButtonGroup
ColorPicker
Pager
Styling
Chat
MultiColumnComboBox
Dialog
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Accessibility
Effects
Licensing
PivotGridV2
ScrollView
Switch
TextArea
BulletChart
QRCode
ResponsivePanel
Wizard
CheckBoxGroup
Localization
Barcode
Breadcrumb
Collapsible
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
TimePicker
FloatingActionButton
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
StockChart
ContextMenu
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SmartPasteButton
PromptBox
SegmentedControl
LLM Kit
+? more
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Simon
Top achievements
Rank 2
Iron
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Grant
Top achievements
Rank 3
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?