Telerik Forums
Kendo UI for jQuery Forum
2 answers
415 views

Hi I have one requirement in Kendo  UI Grid pagination.

How to show

X items / rows in 1st page

X+1 items / rows in 2nd page

X+2 items / rows in 3rd page

I have tried bellow code but not worked, it will show 2 items per page because of latest query selection.

$("div[kendo-grid]").data().kendoGrid.dataSource.query({pageSize: 3, page:1});

$("div[kendo-grid]").data().kendoGrid.dataSource.query({pageSize: 4, page:2});

$("div[kendo-grid]").data().kendoGrid.dataSource.query({pageSize: 2, page:3});

 

Dimiter Topalov
Telerik team
 answered on 05 Apr 2016
3 answers
259 views

Hello,

I am trying to implement a dynamic tabstrip. Below is the code snippets after which I will try to explain the problem I am facing.

HTML:

<div class="text-module">
    <div k-animation="false" class="basic"
         k-options="vm.tabOptions"
         k-data-source="vm.tabsToDisplay"
         k-data-content-url-field="'contentUrl'"
         k-data-text-field="'title'"
         ng-model="vm.tabToSelect">
    </div>
</div>

Data source collection:

vm.tabsToDisplay = new kendo.data.DataSource();
vm.tabItemsSource = [
    {
        id: 1,
        title: 'Title1',
        contentUrl: '/App/Modules/MyModule/Views/a.html',
        Type: 'X',
    },
          {
        id: 2,
        title: 'Title2',
        contentUrl: '/App/Modules/MyModule/Views/b.html',
        Type: 'Y',
    },
];

Method to change tab source based on let's say a button click (toggle)

            function filterTabsToDisplay() {
//vm.ToggleOption could be either X or Y
                vm.filteredTabs = _.filter(vm.tabItemsSource, function (tab) { return tab.Type === vm.ToggleOption; });
                vm.tabsToDisplay.data(vm.filteredTabs);
            }

Tab options:

//Below stuff can be removed; exists for logging purpose only
vm.tabOptions = {
    select: function (e) {
        console.log("Selected: " + e.item.innerText);
    },
    activate: function (e) {
        console.log("Activated: " + e.item.innerText);
    },
    show: function (e) {
        console.log("Shown: " + e.item.innerText);
    },
    contentLoad: function (e) {
        console.log("Content loaded in " + e.item.innerText);
    },
    error: function (e) {
        console.log("Loading failed with " + e.xhr.statusText + " " + e.xhr.status);
    }
};

Tab selection:

function selectTab(tabToSelectId) {
    vm.tabToSelect = _.filter(vm.filteredTabs, function (tab) { return tab.id === tabToSelectId; })[0].title;
}

 

By default value of "vm.ToggleOption" is X which means 1 tab is shown to user. If I see the network tab when this happens, I see that "a.html" gets loaded dynamically. This page is an html page with angular controller attached. So the controller gets initialized as well. If I toggle to Y, "b.html" is loaded and its controller initialized. Everything is good so far.

Now, If I toggle back to X, "a.html" gets loaded again (I see this in network tab) which means the controller associated with this html gets initialized again. This is a problem because when the second load of "a.html" happens, the controller created during previous load already exists and hence I now have two instances of same controller which for me is a problem. If I continue to switch the toggle, every time, a new controller gets created which is quite problematic.

My question is, is this expected behavior when I use "k-data-content-url-field" option. Is there any way I can control this behavior so that it doesn't load the associated html every time?

Also, I have observed that this happens only when I change the bounded data source in some way (using filterTabsToDisplay method). If I have static tab strip like below, this problem doesn't arise.

    <div class="text-module" ng-if="vm.ToggleOption=='X'">
        <div kendo-tab-strip k-animation="false" id="tabstrip1" class="basic">
            <ul>
                <li class="k-state-active">
                    <span>Title1</span>
                </li>
            </ul>
            <div>
                <div ng-include="'/App/Modules/MyModule/Views/a.html'"></div>
            </div>
             
    <div class="text-module" ng-if="vm.ToggleOption=='Y'">
        <div kendo-tab-strip k-animation="false" id="tabstrip2" class="basic">
            <ul>
                <li class="k-state-active">
                    <span>Title2</span>
                </li>                           
            </ul>
            <div>
                <div ng-include="'/App/Modules/MyModule/Views/b.html'"></div>
            </div>
        </div>
    </div>
</div>

Regards,

Vinod

Petyo
Telerik team
 answered on 05 Apr 2016
5 answers
1.6K+ views

Hi

I often set some default values or values from the database in my form widgets. Now this works very well but if I clear the form beforehand using

$('#myform')[0].reset();

the widgets don't seem to accept the values anymore, e.g. myKendoDropDown.select(1) stopps working. This is true for other widgets as well.

What am I missing here ?

Kind regards

Alex

Alex
Top achievements
Rank 1
Iron
 answered on 05 Apr 2016
2 answers
196 views
Stored Proc retrieved data but didn't populate DropDownList. Got this: Unhandled exception at line 38, column 9953 in http://localhost:65133/Scripts/kendo/2016.1.226/kendo.all.min.js

0x800a01b6 - JavaScript runtime error: Object doesn't support property or method 'compareFilters'
Dimiter Topalov
Telerik team
 answered on 05 Apr 2016
1 answer
108 views

Hi

I have a Kendo grid with first 4 columns that are frozen. When i click on Inline Edit, all editable column show up as editable. However when i cancel the edit, only the columns that are frozen become non editable. the columns that are not frozen still remain as editable and the Update / Cancel button still remains and does nothing on further press. it doesnt change itself back to "Edit" button.

Not sure what is wrong here. Code attached below. Any help is appreciated.

@(Html.Kendo().Grid<GoldenBook>()
      .Name("grid")
      .Columns(columns =>
      {
          columns.Bound(p => p.Id).Width(100).HiddenField();
          columns.Bound(p => p.SORId).Width(100).HiddenField();
          columns.Bound(p => p.SOR).ClientTemplate("#=SOR.SOR#").EditorTemplateName("SORList").Width(150).MultiFilterableSearch().Locked(true);
          columns.Bound(p => p.Company).Width(100).MultiFilterableSearch().Locked(true);
          columns.Bound(p => p.GLAccount).Width(150).MultiFilterableSearch().Locked(true);
          columns.Bound(p => p.AccountingUnit).Width(150).MultiFilterableSearch().WrapHeader().Locked(true);
          columns.Bound(p => p.GLAccountType).Width(200).MultiFilterableSearch().WrapHeader();
          columns.Bound(p => p.GLAccountCategory).Width(300).MultiFilterableSearch().WrapHeader();
          columns.Bound(p => p.GLAccountName).Width(500).MultiFilterableSearch();
          columns.Bound(p => p.isActive).Width(100).MultiFilterableSearch();
          columns.Bound(p => p.DateModified).Width(200).DateTimeFormat().MultiFilterableSearch();
          columns.Bound(p => p.UserId).Width(200).MultiFilterableSearch();
          columns.Command(command => { command.Edit().Text("Edit"); }).Width(200);
      })
          .HtmlAttributes(new { style = "width: 99.5%; " })
            .Scrollable()
            .Sortable()
            .Reorderable(reorderable => reorderable.Columns(true))
            .Resizable(resizable => resizable.Columns(true))
            .Filterable()
            .ColumnMenu()
            .Events(e => e.Edit("OnEdit"))
            .Pageable(pageable => pageable
                .Refresh(false)
                .PageSizes(new int[] { 20, 50, 100, 500, 1000 })
            )
            .Editable(editable => { editable.Mode(GridEditMode.InLine).CreateAt(GridInsertRowPosition.Top); })
            
            .ToolBar(toolbar =>
            {
                toolbar.Template(
                @<text>
<div class="toolbar">
    <div id="gridtoolbar">
        <div id="gridtoolbar-left">@item.CreateButton()</div>
        <center>
<div id="gridtoolbar-main">@ViewBag.Title
</div>
        </center>
        <right>
<div id="gridtoolbar-right">
            <a class="k-button k-button-icontext k-grid-excel" href="#"><span class="k-icon k-i-excel"></span>Export to Excel</a>
            <input id="chkAllPages" type="checkbox" ng-model="allPages" ng-change="changeAllPages()" />&nbsp;&nbsp;All Pages
</div>
        </right>
    </div>
</div>
</text>);
            })
            .Excel(excel => { excel.FileName(@ViewBag.Title + ".xlsx"); excel.Filterable(true); excel.AllPages(false); })
            .DataSource
            (dataSource => dataSource
                .Ajax()
                .Batch(false)
                .ServerOperation(false)
                .PageSize(50)
                .Events(events => { events.Error("onError").RequestEnd("onRequestEnd"); })
                .Model(model =>
                {
                    model.Id(p => p.Id);
                    model.Field(p => p.Id).DefaultValue(0);
                    model.Field(p => p.SORId).DefaultValue(0);
                    model.Field(p => p.DateModified).DefaultValue(DateTime.Now);
                    model.Field(p => p.UserId).DefaultValue(@Utils.GetUserName());
                    model.Field(p => p.SOR).DefaultValue(new SORList() { SORId = 0, SOR = "- Select SOR -" });
                })
                .Create(update => update.Action("Create=GoldenBook", "Admin").Data("sendAntiForgery"))
                .Read(read => read.Action("ReadGoldenBook", "Admin"))
                .Update(update => update.Action("UpdateGoldenBook", "Admin").Data("sendAntiForgery"))           
            )
    )


<script type="text/javascript">
    function OnEdit(e) {
        if (e.model != null && e.model.isNew() == false) {
            $('input[name=Id]').parent().html(e.model.Id);
            $('input[name=SORId]').parent().html(e.model.SORId);
            $('input[name=SOR]').parent().html(e.model.SOR.SOR);
            $('input[name=Company]').parent().html(e.model.Company);
            $('input[name=GLAccount]').parent().html(e.model.GLAccount);
            $('input[name=AccountingUnit]').parent().html(e.model.AccountingUnit);
        }
        if (e.model != null && e.model.isNew() == true) {
            $('input[name=Id]').parent().html(e.model.Id);
            $('input[name=SORId]').parent().html(e.model.SORId);
        }
    }
</script>

Nikolay Rusev
Telerik team
 answered on 05 Apr 2016
1 answer
1.1K+ views
Is it possible to bind to keyboard events in the text box editor of a grid cell (or column) in batch edit mode. ALSO, I want to via script set the focus to particular column editor, say when a row is added to set the focus to the second column . Can that be done?
Boyan Dimitrov
Telerik team
 answered on 05 Apr 2016
3 answers
321 views

I alter css and rotated vertically, but how to keep the position always to right side of the grid

Stack Overflow question

 

 

 

Radoslav
Telerik team
 answered on 05 Apr 2016
6 answers
218 views

Hello,

I have 4 data points on this line chart, and it looks like the last data point is getting cutoff.  (Actually is being combined into the third data point).

Example here: https://jsbin.com/yejage/3/edit

It will show the last data point if I change the categoryAxis type to "category" or even if I change the "Date" value of the last data point to "T05:00:00" as the Time, instead of "T00:00:00".

Am I missing something here?  Would like to keep categoryAxis as type="date" to take advantage of built-in date filtering and formatting.  Would also like to not include the time, even though it is shown in the example.

Thanks for your help.

DVS InteleStream
Top achievements
Rank 1
 answered on 04 Apr 2016
1 answer
265 views

Help me please.
how to stretch the contents of the table the full width and add x-scroll?

 

 

<style>

#grid {

overflow: scroll;

}

</style>

<div id="grid"></div>

 

 

                $("#grid").kendoGrid({
                    columns: _columnsObject,
                    dataSource: {
                        data: _dataSourceObject,
                        
                    },
                     resizable: true,
                     
                });
Pavlina
Telerik team
 answered on 04 Apr 2016
3 answers
480 views

Okay so what I'm trying to do is relatively simple but I can't figure out how to get it work properly.

I have a grid that is using inline editing. I don't really care for the Kendo Toolbar on top of the grid so I have an "Add New" button that is in a div outside of the grid. My question is, how do I call the Kendo Add New event when that button is clicked so that a new entry in the grid appears?

Thanks!

Patrick | Technical Support Engineer, Senior
Telerik team
 answered on 04 Apr 2016
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
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Top users last month
Miljana
Top achievements
Rank 2
Iron
Iron
Joel
Top achievements
Rank 3
Bronze
Bronze
Bronze
Cynthia
Top achievements
Rank 1
John
Top achievements
Rank 1
Iron
Mozart
Top achievements
Rank 1
Iron
Veteran
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?