Telerik Forums
Kendo UI for jQuery Forum
7 answers
449 views
Hi,
I have a Kendo grid that looks like :
@(Html.Kendo().Grid<UserHolidayRightDto>()
.Name("gridHoliday")
.ToolBar(tool=>tool.Create())
 
.Columns(columns =>
{
columns.Bound(p => p.Date).Format("{0:MM/dd/yyyy}").Title("Date added");
columns.Bound(p => p.ValidForYear).Title("For year");
columns.ForeignKey(p => p.RightTypeId, (System.Collections.IEnumerable)@Model.HolidayRightsView, "Id", "Name").Title("Right type").HtmlAttributes(new{@Id="HolidayRightsDropDown"});
columns.Bound(p => p.Days).Title("Days");
columns.Bound(p => p.Comment).Title("Comment");
columns.Command(command => { command.Edit(); command.Destroy(); }).Width(172);
})
.Scrollable(s=>s.Height(200))
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Events(e=>e.Edit("edit"))
.Events(e=>e.DataBound("onDataBound"))
.DataSource(dataSource => dataSource
.Ajax()
// .Batch(true)
// .ServerOperation(false)
.Model(model =>
{
model.Id(p => p.Id);
model.Field(p => p.ValidForYear).Editable(false).DefaultValue(@DateTime.Now.Year);
model.Field(p => p.Date).Editable(false);
})
.Events(e=>e.RequestEnd("UpdateWindow"))
.Read(read=>read.Action("ReadData","HolidayRights",new {id=@Model.Employee.PersonID}))
.Create(update => update.Action("EditingInline_Create", "HolidayRights",new {personId=@Model.Employee.PersonID}))
.Update(update => update.Action("EditingInline_Update", "HolidayRights"))
.Destroy(update => update.Action("EditingInline_Destroy", "HolidayRights"))
 ))

I would like to make my foreign key column editable in create mode and disabled in edit mode.  I've tried solutions like :
$("#HolidayRightsDropDown").attr("readonly", true);

and
var d = document.getElementById("HolidayRightsDropDown");
 d.disabled = true;

but without success.

Any suggestions?
Jayesh Goyani
Top achievements
Rank 2
 answered on 08 Jun 2013
1 answer
439 views
After some research and combining of two forum posts, I managed to get this working. I know there are others working on this.

first, implement a resize handler when the splitter is resized.
$("#workSplitter").kendoSplitter({
    orientation: "horizontal",
    panes: [
        { collapsible: false, size: "20%" },
        { collapsible: false, size: "80%" }
    ],
    resize: function () {
        window.setTimeout(function () {
            if (tabExists("Transactions")) {
                resizeGrid("#mainGrid");
            }
            resizeGrid("#activityGrid");
        }, 1);
    }
});

...Is where I call resizeGrid. He's the code from another post with added parameter for re-use:
function resizeGrid(gridSelector) {
    var element = $(gridSelector),
        dataArea = element.find('.k-grid-content'),
        elementHeight = element.innerHeight(),
        otherElements = element.children().not('.k-grid-content'),
        otherElementsHeight = 0;
    otherElements.each(function () {
        otherElementsHeight += $(this).outerHeight();
    });
    dataArea.height(elementHeight - otherElementsHeight);
}
But, as the grid is in a TabStrip, it will only resize to the size of the Tab it's on. If you want the Grid to re-sizeto 100% of the Splitter Pane,
the TabStrip must re-size to 100% of the Pane width/height.

This I did with CSS (stolen from another post but changed slightly):

#workTabs {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: auto;
    height: auto;
}
 
#workTabs > .k-content {
    position: absolute;
    top: 34px;
    bottom: 0;
    left: 0;
    right: 0;
}
Originally the second set of settings were applied to classes .k-tabstrip and .k-content. This caused big issues with an embedded TabStrip in the detail Template that I did not want resized. So the change to "#workTabs > .k-content" was enough to limit this to the first children only. Setting attributes on class .k-tabstrip  did not seem to be needed.

Hope this helps

Original Post for making TabStrip 100% of Splitter pane.
http://www.kendoui.com/forums/ui/tabstrip/forcing-tabstrip-to-take-up-100-of-it-s-parent-container.aspx#2398868

Original post for making grid 100% of Splitter pane, allowing for other elements
http://www.kendoui.com/forums/mvc/grid/grid-100-height.aspx










Mike
Top achievements
Rank 1
 answered on 08 Jun 2013
2 answers
134 views
I'm having a problem getting my grid to bind to some json data. I've searched the forums for a solution but no luck.

The following code throws an error of 'Unable to get value of property 'length': object is null...':


$("#search-grid").kendoGrid({
    dataSource: {
        transport: {
            read: {
                url: "a URL"
            }
        },
        schema: {
            data: "data"
        }
    },
    columns: [{field:"Name",title:"Name"}]
});
Based on some other forum posts, this is indicative of a bad json response so i copied and pasted the json from the response to a javascript variable and it works so I'm not sure what I'm doing wrong.

This works:
var testdata = { "data": [{ "Name": "TestY" }] };
 
var searchViewModel = kendo.observable({
    init: function () {
        $("#search-grid").kendoGrid({
            dataSource: {
                data: testdata,
                /*
                transport: {
                    read: {
                        url: "a URL"
                    }
                },
                */
                schema: {
                    data: "data"
                }
                 
            },
            columns: [{field:"Name",title:"Name"}]
        });
    }



I've validated my response by other means and it is valid json so I'm not sure what to try next.  Something is "wrong" with it but I don't know what.

here is the raw response:

HTTP/1.1 200 OK
Content-Length: 27
Content-Type: application/JSON
Server: Microsoft-IIS/7.5
X-Powered-By: ASP.NET
Date: Fri, 07 Jun 2013 20:00:59 GMT
 
{"data":[{"Name":"TestY"}]}


Thanks in advance


Any ideas?
Cody
Top achievements
Rank 1
 answered on 07 Jun 2013
2 answers
221 views
I know that I can set options on a custom widget if I instantiate the widget in code, so that the following should output "foo" to the console.
var MyWidget = kendo.ui.Widget.extend({
    init: function(element, options) {
        kendo.ui.Widget.fn.init.call(this, element, options);
 
        console.log(options.myOption);
    },
    options: {
        name: "MyWidget"
    }
});
kendo.ui.plugin(MyWidget);
 
$("#widgetRoot").kendoMyWidget({ myOption: "foo" });
Is there any way that I can do the same thing using declarative binding? I get as far as
<span id="widgetRoot" data-role="mywidget" data-bind="X"></span>
but there doesn't seem to be anything I can put in for X that gives me access to the options parameter.  I haven't been able to find anything in the blog  posts or documentation to shed light on this.
Jake
Top achievements
Rank 1
 answered on 07 Jun 2013
4 answers
682 views
I want to create a Grid with a Toggle button in the first column.

Each Row describes a layer for a map:

 1) name,  2) size, 3) type, etc.

In column 0, I would like to put a two-state toggle button.

[KEEP/DELETE] (if  this layer already exists)

or a different button if the layer does not exist

[ADD/SKIP] 

I have seen the checkbox in the GRID: http://www.kendoui.com/forums/ui/grid/grid-checkbox.aspx , but I think that to add four columns to the row (and to change it to a radio) would be confusing.

Or is there some other UX idea that I am just blanking out on.

Once the user has determined which rows to keep, delete, or to download, I will go through the .data() and do the appropriate actions.


Dr.YSG
Top achievements
Rank 2
 answered on 07 Jun 2013
3 answers
250 views

Validation used for a field in KendoGrid works fine on currently being edited cell when I try to select other cell.But It doesn't work when I try to sort any column or use filter. Is it possible to prohibit user from sorting or filtering till validation for the field passes.

Code used for validation in datasource for one of field.
01.Project:{
02.editable:true,
03.validation: {
04.custom: function(input) {
05.if(input.val()=="") {
06.input.attr("data-custom-msg", "Message");
07.return false;
08.}
09.else
10.return true;
11.}
12.}
13.}
Daniel
Telerik team
 answered on 07 Jun 2013
1 answer
6.7K+ views
Hi

I want to store selected item state. I can't trigger 'select' event properly.
    $('#groups').kendoDropDownList({
        dataSource: [
            { text: "No group", value: "none" },
            { text: "By type", value: "type_label" },
            { text: "By route", value: "route_label" },
            { text: "By status", value: "status_label" }
        ],
        dataTextField: "text",
        dataValueField: "value",
        select: function(e){
            var selectedDataItem = this.dataItem(e.item.index());
        set_global_setting ("group_state", dataItem.value);
// ... code which depends on selectedDataItem and works this.dataSource
        }
    }).data("kendoDropDownList").select(function(dataItem){
        return dataItem.value === get_global_setting("group_state");
    });
 
    var groups_dropdown = $('#groups').data("kendoDropDownList");
    groups_dropdown.trigger("select", {item : groups_dropdown.dataItem()}); // does not work since 'select' event expects 'e.item' as 'li'
When user changes selected value 'e.item' in 'select' event is a 'li'.
When I change selected value programmaticlly I should specify next selected item not as dataItem but as 'li'.
How can I do this?
Maybe I should somehow change 'selectedDataItem' definition in 'select' event?
Dimiter Madjarov
Telerik team
 answered on 07 Jun 2013
1 answer
133 views
Hi,

I have an viewmodel with an observable array of objects, and a computed selectedObject.  I'm attempting to bind a KendoListView to an observable array in selectedObject, but the ListView doesn't get updated.

There's a fiddle demonstrating the issue here:

http://jsfiddle.net/JrJ2q/3/

I'd appreciate any support you could provide.

Thanks,
John
Atanas Korchev
Telerik team
 answered on 07 Jun 2013
2 answers
97 views
Hello,

I am having a problem sorting by the column that I enabled a custom editor for. 

I basically followed the sample at http://demos.kendoui.com/web/grid/editing-custom.html 

How would you go about sorting by the "Category" column? The column it self is an object, so I think is getting confused.

Any ideas?

Thanks!
Covo
Ricardo
Top achievements
Rank 1
 answered on 07 Jun 2013
3 answers
182 views
This is for Kendo UI version 2013.1.514.340.

Here is my MVC view:

<script src="~/Scripts/jquery-1.7.1.js"></script>
<script src="~/Scripts/kendo.web.min.js"></script>
<script src="~/Scripts/kendo.aspnetmvc.min.js"></script>
<link href="~/Styles/examples.css" rel="stylesheet" />
<link href="~/Styles/kendo.common.min.css" rel="stylesheet" />
<link href="~/Styles/kendo.default.min.css" rel="stylesheet" />

@using Kendo.Mvc.UI
@model List<CV.Prototype.ViewModels.MyRecord>

@(Html.Kendo().MultiSelect()
      .Name("categoryMultiselect")
      .DataTextField("Name")
      .DataValueField("Id")
      //SERVER BINDING
          .BindTo(Model)
          .Value(Model)   
      )

My controller is simply:
        public ActionResult Index()
        {

            var x = new List<MyRecord>
                {
                    new MyRecord {Id = 1, Name = "Name1"},
                    new MyRecord {Id = 2, Name = "Name2"},
                    new MyRecord {Id = 3, Name = "Name3"},
                    new MyRecord {Id = 4, Name = "Name4"}
                };
            return View(x);
        }

All the records display inside the grey boxes, but are not inside the input text box. Also the throbber is constantly displaying. Apart from this it functions correctly both with Server and Ajax binding. Any clues as to what I might be missing?
Daniel
Telerik team
 answered on 07 Jun 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
Map
Drag and Drop
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
MultiColumnComboBox
Dialog
Chat
DateRangePicker
Checkbox
Timeline
Drawer
DateInput
ProgressBar
MediaPlayer
ImageEditor
TextBox
OrgChart
Effects
Accessibility
PivotGridV2
ScrollView
BulletChart
Licensing
QRCode
ResponsivePanel
Switch
Wizard
CheckBoxGroup
TextArea
Barcode
Breadcrumb
Collapsible
Localization
MultiViewCalendar
Touch
RadioButton
Stepper
Card
ExpansionPanel
Rating
RadioGroup
Badge
Captcha
Heatmap
AppBar
Loader
Security
TaskBoard
Popover
DockManager
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
TimePicker
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
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?