Telerik Forums
Kendo UI for jQuery Forum
1 answer
288 views
I'm trying to access a Dependent Method's calculated value in JavaScript after the binding.  Why doesn't this work?
// Create an observable view model object.
var person = kendo.observable({
  firstName: "John",
  lastName: "DeVight",
 
  // Create a dependent method (calculated field).
  fullName: function() {
    // The "get" function must be used so that changes to any
    // dependencies will be reflected in the dependent method.
    return this.get("firstName") + " " + this.get("lastName");
  }
});
 
// Bind the view model to the personFields element.
kendo.bind($('#personFields'), person);
 
// This produces the function() without handing off the value to the JS variable
var fullName = person.get("fullName");

Or trying it by replacing the "this" with "person"...

// Create an observable view model object.
var person = kendo.observable({
  firstName: "John",
  lastName: "DeVight",
 
  // Create a dependent method (calculated field).
  fullName: function() {
    // The "get" function must be used so that changes to any
    // dependencies will be reflected in the dependent method.
    return  person.get("firstName") + " " + person.get("lastName");
  }
});
 
// Bind the view model to the personFields element.
kendo.bind($('#personFields'), person);
 
var fullName = person.get("fullName");

If I did something similar in KnockoutJs, it would be like this below (and this works): (jsFiddle: http://jsfiddle.net/piercove/S6Q8D/2/)

var ViewModel;
 
// Create an observable view model object.
var person = function() {
    var self = this;
    self.firstName = ko.observable("John");
    self.lastName = ko.observable("DeVight");
 
    // Create a dependent method (calculated field).
    self.fullName = ko.computed(function () {
        return self.firstName() + " " + self.lastName();
    });
};
 
// Match to the global JS object
ViewModel = new person();
 
// Bind the view model to the personFields element.
ko.applyBindings(ViewModel, document.getElementById("result"));
 
var fullName = ViewModel.fullName();
 
$("#result").html(fullName);
So, the question is, how do I pull off the equivalent in Kendo MVVM.  I try to keep my code in JS files and not in the web page itself (Razor view in ASP.NET MVC to be exact).  In my JS files, I have a unique "ViewModel" object that creates a new instance of the view model for that page, so that all the observables and internal functions can be accessed by any other functions in that same JavaScript file.  I'm wondering how to pull off something similar with Kendo MVVM.

Thanks!
Alexander Popov
Telerik team
 answered on 10 Oct 2013
3 answers
117 views
Hi guys,
I'm having some issues trying to customize a filter (as a dropdownlist ) in a grid.
The result is that if I use "is equal to", the result is always nothing... (no errors, just no records)
while if I use "contains" or  "starts with" I get an error like "Object 1 has no method 'toLowerCase'" (that goes deep into kendo's and jquery's js)

here my code

column definition:
{
                    field: "Role",
                    title: "ruolo",
                    template : "<span>${Role.Name}</span>",
                    filterable: {
                        ui: RoleFilter,
                        extra: false
                    },
                    editor: function (container, object) {
                        SetRoleSelect(container, object);
                    }
                },
 
dataSource definition
fields: {
                        prop1 : {type:"string"}
                        Role: {
                            Id: { type: "int", editable: false },
                            Name: { type: "string", editable: true, validation: { required: true } },
                            Descrizione: { type: "string", editable: true, validation: { required: false } },
                            Visible: { type: "boolean", editable: true },
                            Rango: { type: "number", editable: true, validation: { required: true, min: 0 } }
}
and my function
RoleFilter: function (element) {
        element.kendoDropDownList({
            dataTextField: "Name",
            dataValueField: "Id",
            dataSource: {
                transport: {
                    read: {
                        url: "my url returning a list of Role object",
                        cache: true
                    }
                }
            },
            optionLabel: "Select a Role"
        });
    }
My guess is that there's a kind of mismatch between the object inside the filter and the in the grid's datasource...
but objects are actually the same!

Where I am doing wrong? thanks!
Fabio
Dimiter Madjarov
Telerik team
 answered on 10 Oct 2013
7 answers
1.3K+ views
In my MVC project, I have a view which displays a list of roles (as in user roles), and an add button, which pops up a KendoUI window, rendering a Create view.
This is how my window snippet looks like:
@(Html.Kendo().Window()
           .Name("window")
           .Title("Role")
           .Content("loading...")
           .LoadContentFrom("Create""RolesPermissions", Model.Role)
           .Modal(true)
           .Width(550)           
           .Height(300)                      
           .Visible(false)
          )

And this is what I use to open(popup) and close the window
    $(document).ready(function () {
        var wnd = $("#window").data("kendoWindow");
 
        wnd.bind("refresh"function (e) {
            var win = this;
            $("#close").click(function() {
                win.close();
            });
        });
 
        $("#open").click(function (e) {
            wnd.center();
            wnd.open();
        });
 
    });

My question is, how do I close the window, if and only if the action is successful?

        [HttpPost]
        public ActionResult Create(RoleModel model)
        {
 
            if (ModelState.IsValid)
            {
                RoleDto role = new RoleDto
                    {
                        Name = model.Name,
                        Description = model.Description
                    };
 
                var roleAdded = _rolePermissionsRepository.AddRole(role);
                if (roleAdded != null)
                {
                    //CLOSE KENDOUI WINDOW
                }
                else
                {
                    //PRINT ERROR MSG TO KENDOUI WINDOW
                }
            }
            return View();
        }

I would like to know how to handle the portions that I have commented.

Basically, if the role is added succesfully, I would like the window to close automatically, taking me back to my list of roles, which I will then update. If there's any kind of error, the window will remain open, showing an error msg.
Thomas
Top achievements
Rank 2
 answered on 10 Oct 2013
1 answer
128 views
Hi,

I used the theme builder and got the theme where I wanted.  I saved the output CSS into a CSS file and referenced it after kendo.common.min.css.  I was using the default theme, so I commented that line out.  I've double checked spellings and file locations and they are correct.

When I load my page, I get a completely different look than I intended in my theme builder work.  Also, no images for the listview pager or, anywhere else Kendo for that matter.

I believe I followed the instructions as stated on the page.   Am I missing something?

Here are the include lines:
<link href="@Url.Content("~/Content/kendo.compatibility.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.dataviz.default.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.common.min.css")" rel="stylesheet" type="text/css" />
<link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.dataviz.min.css")" rel="stylesheet" type="text/css" />

@*<
link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.default.min.css")" rel="stylesheet" type="text/css" />*@

<link href="@Url.Content("~/Content/kendo/2013.2.918/kendo.dataviz.default.min.css")" rel="stylesheet" type="text/css" />
 

THIS IS MY CUSTOM THEME....
<link href="@Url.Content("~/Content/kendo/2013.2.918/WFHCustom/KendoCustomTheme.css") rel="stylesheet" type="text/css" />
 
<script src="@Url.Content("~/Scripts/kendo/2013.2.918/kendo.all.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo/2013.2.918/kendo.aspnetmvc.min.js")"></script>
<script src="@Url.Content("~/Scripts/kendo.modernizr.custom.js")"></script>
Dimo
Telerik team
 answered on 10 Oct 2013
5 answers
272 views
Hi, 

I have 2 tabstrips, one parent and one child. In IE this renders bullet points beside each tab. Works fine in Chrome, but my target browser is IE (unfortunately).

I have created a very simple example on JS Bin to illustrate this http://jsbin.com/EPoDUpE/2. Click Tab 3. This shows the child tabstrip with items Tab3.1, Tab3.2 etc. You will see each of these tabs have bullet points beside them. Am I doing something wrong? Or is this a bug with the framework?

I have another issue with the display of the child tabstrip and that is, it indents itself, I can't seem to prevent this. I would like it to be the exact width and inline with the parent tabstrip. How do I correct this?

Thanks,
Ade
Dimo
Telerik team
 answered on 10 Oct 2013
3 answers
89 views
Dear Kendo Team,
As you could see in the attach files, if I group with multiple columns, the behavior of the subrows seem to be a bit strange....but it's well displayed if I expand the group
This issue doesn't appear with chrome...
Could you provide me a solution for this issue?
Thanks in advance 
Iliana Dyankova
Telerik team
 answered on 10 Oct 2013
1 answer
97 views
Hi
I get the data back just fine, but I am not able to render it in the grid. My grid rendering function is here:

function RenderDetailedBvtResults(data) {
debugger;
$('#gridBvtDetails').kendoGrid({ 
data: data,
scrollable: false,
toolbar: 'Details',
});
}
Alexander Valchev
Telerik team
 answered on 10 Oct 2013
1 answer
433 views
Hi,

I've noticed that if you press Enter key from keyboard when no item is selected in combobox, the first item automatically get selected. Is there anyway to prevent this in configuration settings without using javascript events? I don't want to add an extra keydown event each time i use a combobox in my pages.  If there is an enable/disable option for this behavior it will be great. (i am using aspnet-mvc wrapper by the way...)

Thank you.


Noldor
Top achievements
Rank 1
 answered on 10 Oct 2013
1 answer
180 views
I have a page with 4 autocomplete fields and one text field all in a row. The fields are used to apply filters to a grid. When I enter something in the plain text field, and apply the filters to the grid, everything works fine. The filters are applied and the data in the grid is reduced. When I then click a link in the grid to view the detail page for the record, and then click the back button to get back to the grid, the value that was in the text field is displayed in the first autocomplete box for some reason. 

I save the grid state to localStorage using the dataBound event of the grid:

$('.grid').kendoGrid({
    ...
    dataBound: this.saveGridState
    ...

Where this.saveGridState is: 

var grid = $('.grid').data('kendoGrid');
  var dataSource = grid.dataSource;
  var state = JSON.stringify({
    page: dataSource.page(),
    pageSize: dataSource.pageSize(),
    sort: dataSource.sort(),
    group: dataSource.group(),
    filter: dataSource.filter()
  });
  localStorage.setItem('gridState', state);

I load the state when the document is ready using:
$(document).ready(function(){
    var state = JSON.parse(localStorage.getItem('gridState'));
    var grid = $('.grid').data('kendoGrid');
    if(state && Object.keys(state).length > 0) {
      if(state.filter && state.filter.filters) {
        ctx.showFiltersInInputs(state.filter.filters);
      }
      grid.dataSource.query(state);
    }
    else {
      grid.dataSource.read();
    }
  });

I initially thought that the function I use to put the filters back into their inputs was mistakenly putting the data in the wrong field. However, if i set a breakpoint in chrome before any of the kendo related javascript, I still see the value in the wrong field. It appears the autocomplete is somehow persisting the value in the plain text field when I browse to the detail page and sticking it in the first autocomplete. Seems really weird. Any idea what this could be?

Thanks,

Troy
Kiril Nikolov
Telerik team
 answered on 10 Oct 2013
1 answer
224 views
Using 2013.9.18

I'm defining a kendoScheduler with 
timezone: "Etc/UTC"
It works great, in my database the times are stored in UTC and depending on whether I load the page in San Francisco (GMT+7) or Minneapolis (GMT+5), the same event shows two different starting times depending on the user's geographical location. The kendoScheduler seems to convert the dates to local time and this is great for me. (The documentation indicates it should do the opposite, but this is the effect I wanted so for now I'm happy).

The problem is that it computes local time wrong. In Minneapolis, it takes GMT and adds 5 and in San Francisco, it takes GMT and adds 7. It should be subtracting these values, not adding them! If it's 00:00 GMT, it's 17:00 the previous day in San Francisco, not 07:00.

Has anyone else had the same sort of issues? Searching the forums, it seems like I'm not the only one encountering this.



Matt Johnson
Top achievements
Rank 1
 answered on 10 Oct 2013
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
Application
Drag and Drop
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
ListBox
DropDownTree
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
PivotGridV2
Licensing
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
+? more
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Rakhee
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?