Telerik Forums
Kendo UI for jQuery Forum
5 answers
902 views

Hi,

I'm using row filters in Kendo-grids with "odata-v4" specified on the data-sources. I'm writing here, because I'm not sure if this is a data-source issue or a grid issue. There are two filter scenarios where errors occur on the server side (ASP.NET MVC):

1) Kendo's current implementation still uses the old "substring" instead of the OData v4 "contains" expression. The server barks.

2) Since GUIDs are handled as strings, they are wrapped in single quotation marks. The server barks.

I'm using Kendo UI version 2015.2.624.

The following hack works around those issues. It would be great if those two scenarios could be fixed in the library.

 

fixODataV4FilterParameterMap = function (options) {
// This is needed for Kendo-grid's filters when using OData v4.
 
    // Call the default OData parameterMap.
    var result = kendo.data.transports.odata.parameterMap(options);
 
    if (result.$filter) {
         
        result.$filter = result.$filter.replace(/('[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')/ig, function (x) {
 
        // Remove the single quotation marks around the GUID (OData v4).
        return x.substring(1, x.length - 1);
        });
 
        // Replace "substring" with "contains" (OData v4)
        result.$filter = result.$filter.replace(/substringof\((.+),(.*?)\)/, "contains($2,$1)");
    }
    return result;
};

 

Regards,

Kasimier Buchcik

Casimodo
Top achievements
Rank 1
 answered on 01 Jul 2015
1 answer
1.1K+ views

I have Kendo UI Professional and I am trying to create a KendoGrid using data from the ViewData.Model
My script looks like this:

@model IEnumerable<WebApplication5.Models.Presentation>
..
<script>

 $(document).ready(function () {

            var dataSource = new kendo.data.DataSource({
                pageSize: 21,
                data: @Model,
                dataType: JSON,
                schema: {
                    model: {
                         fields: {
                                    Name: {},
                                    PresentationFamilyId: {},
                                    SourcePresentationId: {}
                        }
                    }
                }
            });

            $("#grid").kendoGrid({
                dataSource: dataSource,
                height: 550,
                groupable: true,
                sortable: true,
                pageable: {
                    refresh: true,
                    pageSizes: true,
                    buttonCount: 5
                },
                columns: [{
                    field:"Name",
                    title:"Name"
                }, {
                    field:"PresentationFamilyID",
                    title:"Family"
                }, {

                    field:"SourcePresentationID",
                    title:"Source"
                }]
             });
        });

</script>

 My
controller looks like this:

    public ActionResult Index()
    {
         return View(db.Presentations);
    }

I cannot get it to work. I have tried every permutation for DataSource.data that I can think of
but they all generate errors. For instance, the above code complains about “Unexpected token ]”

Tried in controller:            return View(db.Presentations.ToArray()); -- Unexpected Token ]
Changed javascript:

                                        data: @Model.ToArray()     -- Unexpected Token ]

                                        data:  @Model.ToList()

                                                   – The browser shows: data: System.Collections.Generic.List`1[WebApplication5.Models.Presentation],
                                                      with error:
                                                               Unterminated template literal 

                                                      (this is because of the unmatched quote mark)
How do I
specify @Model as my datasource?

Russell
Top achievements
Rank 1
 answered on 01 Jul 2015
1 answer
288 views

Hi,

 I have created an AngularJS project containing an image gallery. Now I would like to display a Telerik Kendo UI Window widget containing a scrollview in order to create a lightbox-effect. Most of it works fine, but I need to be able to dynamically set the initial page. I know that I can set the k-page option, but I'm not sure how to set this value when the user clicks an image. Please observe the following HTML:

<div class="gallery-content">
    <div class="container">
        <div class="gallery-grid" data-ng-show="item.Files.length">
            <div class="picture" data-ng-repeat="File in item.Files"><a ng-href="#" ng-click="openImageLayer($event, File, $index)"><img data-ng-src="/Admin/Public/GetImage.aspx?Image=/Files/Files/Intranet/{{File.FileName}}&amp;Width=200" /></a></div>
            <a href="#" class="btn-add-new hidein-mobile"><span class="icon icon-add-new"></span></a>
        </div>
    </div>
</div>

<div class="popup-holder" kendo-window="imageLayer" k-title="'Billede'" k-on-open="win1visible = true" k-on-close="win1visible = false" k-visible="false" k-modal="true" k-options="kendoWindowOptions">
    <div kendo-mobile-view="view" k-stretch="true" id="scrollview-home">
        <div kendo-mobile-scroll-view="scrollview"
             k-data-source="photos"
             k-content-height="'100%'"
             k-enable-pager="true"
             k-pager-overlay="true"
             k-options="galleryOptions" k-page="{{page}}">
        </div>
    </div>
</div>

 

When the user clicks an image, the following function is called:

        $scope.openImageLayer = function ($event, file, index) {
            $event.preventDefault();
            $scope.activeFile = file;
            $scope.page = index;
            console.log($scope.page);
            $scope.imageLayer.open().center();
        }

 

However, the Scrollview does not observe the $scope.page value. I suspect this is due to the fact that the Scrollview has already been initialized.

Regards,

Peter

Alexander Valchev
Telerik team
 answered on 01 Jul 2015
1 answer
166 views

I have used KendoUI grid in my web application. It runs at batch editing mode, and a date column is in the grid.
For some reasons, I can't using KendoUI datepicker to show the date when a cell in the column clicked. Instead,I must use the jQueryUI datepicker in edting mode.
But when I was showing the jquery date picker, the date can not be displayed with the format which I have set.
Following is my configuration.

 

$("#"+currGrid.options.girdContainerId).kendoGrid({
    dataSource: kendoGridDataSource,
    ...
    columns:[
       ...
       {
        field:'StartDate',
        editor : function(container, options){
                var $input = $("<input />").attr("name",options.field).appendTo(container);
                $input.datepicker({
                    dateFormat:"yy/mm/dd",
                });
        },
        format:"{0:yyyy/MM/dd hh:mm:ss}",
        },
        ...
    },
    ,
    editable: true

I have set the format as "yyyy/mm/dd".But when I focus in the cell, the string likes "Wed Jun 17 2015 15:00:00 GMT+0900 (東京 (標準時))" will be displayed.
How can I control the value displayed in datepicker with format as "yy/mm/dd" when I focus in cell first time?
Best regards
Alexander Valchev
Telerik team
 answered on 01 Jul 2015
1 answer
60 views

Seen on the stock demo of custom editor, if you click to activate the dropdown editor cell, then use the down arrow, it immediately saves the grid row with the next item in the DDL selected. I've tried every event hook possible to prevent this behavior but haven't had success. We still don't have the ability to enable/disable keyboard controls for elements so aside from modifying the source I am kind of stuck here.

Any suggestions? Can we change this behavior in the future?

Daniel
Telerik team
 answered on 01 Jul 2015
1 answer
257 views

Hi, I'm trying to open a context menu on TreeView drop event, but the code below is not working.

HTML:

<!DOCTYPE html>
  
<html lang="en" style="height: 100%">
<head>
    <link rel="stylesheet" href="app.css" />
</head>
<body style="height: 100%">
    <script src="Scripts/jquery-2.1.4.js"></script>
    <script src="Scripts/jquery-ui-1.11.4.js"></script>
    <script src="Scripts/typings/KendoUI/kendo.all.min.js"></script>
    <script src="app.js"></script>
  
    <div id="splPanel" style="height: 98% ">
        <div id="left-pane">
            <div class="pane-content">
                <div id="treeviewTags" style="height: 100%"></div>
            </div>
        </div>
        <div id="center-pane">
            <div class="pane-content">
  
                <ul  id="menu">
                    <li>Value</li>
                    <li>Trend</li>
                    <li>Linear Gauge</li>
                    <li>Radial Gauge</li>
                </ul>
  
            </div>
        </div>
    </div>
</body>
</html>

TypeScript File:

$(function () {
    InitSplittedPanel();
    InitTreeView();
    InitContextMenu();
});
 
function InitSplittedPanel() {
    <kendo.ui.Splitter>$("#splPanel").kendoSplitter({
        panes: [
            { collapsible: true, size: "200px" },
            { collapsible: false }
        ]
    }).data("kendoSplitter");  
}
 
function InitTreeView() {
    <kendo.ui.TreeView>$("#treeviewTags").kendoTreeView({
        dragAndDrop: true,
        dataSource: [
            {
                text: "Automation", imageUrl: "Images/folder-32.png", expanded: true, items: [
                    { text: "Temperature_Adm", imageUrl: "Images/tag-icon.png" },
                    { text: "Temperature_Dev", imageUrl: "Images/tag-icon.png" },
                    { text: "Temperature_TI", imageUrl: "Images/tag-icon.png" }
                ]
            }
        ],
        drag: onDrag,
        drop: onDrop
    }).data("kendoTreeView");
}
 
function InitContextMenu() {
    <kendo.ui.ContextMenu>$("#menu").kendoContextMenu({
        orientation: "vertical",
        target: "#treeviewTags",
        showOn: "drop",
        animation: {
            open: { effects: "fadeIn" },
            duration: 500
        },
        select: function (e) {
            // Do something on select
        }
    }).data("kendoContextMenu");
}

Thanks!

Alexander Popov
Telerik team
 answered on 01 Jul 2015
2 answers
1.2K+ views

 Original question here: http://stackoverflow.com/questions/31138694/kendo-ui-bug-kendo-grid-pager-not-aligned-with-bottom-of-grid

  Recently, I have been using Kendo UI and I have run into the following problem: The pager for my Kendo grid is not flush with the bottom of my grid. I've tried editing the CSS styling of `k-grid-pager` but it does not solve the problem. For added clarification, the pager used to be in the upper left corner BEFORE I made the top margin of the pager 450px (to simply shift it down). However, I would like a fix that is dynamic in the sense that it can adapt to the overall height of the grid. Also note the black border floating off to the side-that is part of the pager, how? They must be hiding a class from me... Or I just don't know it. Anyhow, here is an image of what my messed up grid looks like: ![KendoPls][1]

The CSS code I used to modify the grid and its styling:

#konTable2 {
position:absolute;
left: 150px;
margin-right: -50%;
background-color: rgba(0,0,0,0);
border:0px solid rbga(0,0,0,0);
}
.k-grid tr th {
   border-bottom: 1px solid black;
   text-align: center;
   height:25px;
}
.k-grid tr td{
background-color: #494949;
border-bottom: 1px solid black;
text-align: left;
mix-blend-mode:hard-light;
}
.k-grid-pager {
position: relative !important;
float: left !important;
background-color: lime;
width:900px;
left:50%;
margin-right: -450px;
margin-top:450px;
}

And finally the html/js used to layout the grid: 

    <div id="konTable2"></div>
    <script src="../json/Koncerts.jsonp"></script>
    <script type="text/javascript">
    var myConcerts = concerts;
    $(function() {

    var dataSource = new kendo.data.DataSource({
    data: myConcerts
    });

     $('#konTable2').kendoGrid({
    columns: [{ title: "Artist", field: "artist", template: "<div class='name' style='width:200px'>#= artist #</div>"},
    {title: "Concert", field: "concert", template: "<div class='name' style='width:250px'>#= concert #</div>"},
    {title: "Date", field: "date", template: "<div class='date' style='width:150px'>#= date #</div>"},
    {title: "City", field: "location.city", template: "<div class='name' style='width:150px'>#= location.city #</div>"},
    {title: "State", field: "location.state",template: "<div class='name' style='width:150px'>#= location.state #</div>"}
    ],
    dataSource: {
    data: myConcerts,
    pageSize: 5
    },
    selectable: true,
    sortable: true,
    scrollable: false,
    pageable: {
                refresh: true,
                pageSizes: true,
                buttonCount: 5
            },
    });
    });
    </script>
**<h1>UPDATE</h1>**
I have modified the CSS. I am now mainly modifying `k-pager-wrap` to change the positioning of my pager, and it looks a little better, and more like this:
![KendoGRid Update][2]
*Notice:* I did not include the vertical translation as in the previous example. Now you can see how the pager just wants to chill at the upper left corner of the grid... Also, here is the new relevant CSS:

.k-pager-wrap {
width:900px;
position: relative;
float:right;
left:50%;
margin-right: -450px;
mix-blend-mode: normal !important;
}
.k-grid-pager {
width:900px;
}


  [1]: http://i.stack.imgur.com/fKn7F.png
  [2]: http://i.stack.imgur.com/957GI.png

Jacques
Top achievements
Rank 1
 answered on 01 Jul 2015
6 answers
1.4K+ views

Hi!

So I know I can do this for inline editing, a cell at a time, for example:

edit : function (e) {
        var data = e.model;
        if (data.City === "Detroit") {
           this.closeCell();
        }
        e.preventDefault();
    },

..but if I'm using popup editing, could I disable editing depending on value?

Is there a 'closeRow()' equivalent or anything like that?

Thank you!

 

Dimiter Madjarov
Telerik team
 answered on 01 Jul 2015
4 answers
1.8K+ views

Hello!

When using the grid in a kendo-window the databound event is not triggered. When using the same grid outside of the kendo window the event is triggered like expected.

 

Has anyone else experienced issues like this? Any solutions for this problem?

Dimiter Madjarov
Telerik team
 answered on 01 Jul 2015
3 answers
194 views

I'm trying to set the location of the cursor to the end of the text in my editor.

 Please let me know how I can achieve this goal.

 

Dennis

Alex Gyoshev
Telerik team
 answered on 01 Jul 2015
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
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
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?