Telerik Forums
Kendo UI for jQuery Forum
3 answers
97 views
Hi,
I use the KendoGrid to display some data returned by a MVC3 crontroller.
Data are successfully displayed, but the kendoGrid's pager display "Page 0 of NaN"

Here is my JS: 

        var sectionId = $("#myKendoCombobox").val();
        $("#myKendoDiv").kendoGrid({
            scrollable: true,
            sortable: true,
            pageable: true,
            selecteable: false,
            filterable: true,
            dataSource: {
                    transport: {
                        read: {
                            url: _pathRoot + "GetDataById",
                            data: { sectionId: sectionId },
                            dataType: "json",
                            type: "GET",
                            contentType: "application/json; charset=utf-8"
                        }
                    },
                    schema: {
                        data: "data",
                        total: "total"
                        },
                    pageSize: 1,
            },

            pageable: {
                refresh: true,
                input: true,
                numeric: false
            },       
           columns: [ ... ]
        });


I tried to use un function for the "total" parameter, like this :                         total: function (response) {
                            alert(response.total);
                            return response.total;
                        }
And the message box successfully display my number of items, so it's not a problem of proprty name.

Could you help me to fix that problem ?
Thanks in advance.







Dimo
Telerik team
 answered on 27 Jun 2014
3 answers
1.0K+ views
Using a Grid, what is the event that is fired when something is "grouped".  I want to run a function but only when someone drops a column header into the "group by" area.

Furthermore, is there an event that fires when you remove the grouping.  Meaning you click on the little "x" of the last grouped element.

Thanks,
Jason
Alexander Valchev
Telerik team
 answered on 27 Jun 2014
1 answer
160 views
Hi,

I want to refresh the list of snippet from javascript so that i can change snippet list by changing a option.

i have tried this way but list won't get refresh. any possible way to fix this.

    function PopulateSnippets(data) {
        var editor = $("#Body").data("kendoEditor");
        editor.options.insertHtml.length = 0;
        
        var snippetArray = [];
        $(data).each(function (index, item) {
            snippetArray.push({
                text: item.Text,
                value: item.Value
            });
        });
        editor.options.insertHtml = snippetArray;
    }

Alex Gyoshev
Telerik team
 answered on 27 Jun 2014
1 answer
354 views
Hello,

When uploading files, we have the need to set the withCredentials to false on the XmlHttpRequest. My upload event implementation is as follows:

upload: function (e) {
    var xhr = e.XMLHttpRequest;
    if (xhr) {
        xhr.addEventListener('readystatechange', function (event) {
            if (xhr.readyState == 1) {
                    xhr.withCredentials = false;
                    xhr.setRequestHeader("Authorization", "Bearer " + token);
                    xhr.crossDomain = true;
            }
        });
    }
}

The problem is that the code inside of kendo.all.js for postFormData() overrides the withCredentials value with a "true" after the xhr open event is fired. Thus overriding any setting to the string value of "true", prior to sending.

The code in kendo.all.js is as follows:

xhr.open("POST", url, true);
xhr.withCredentials = "true";
xhr.send(data);

A fix for the issue would be to set the withCredentials value prior to opening the xhr as follows:

xhr.withCredentials = true;
xhr.open("POST", url, true);
 
xhr.send(data);

Please let me know if I am doing something wrong, or if there any plans to change this.
Vladimir Iliev
Telerik team
 answered on 27 Jun 2014
4 answers
234 views
I know this is possible with your typical view, but perhaps this is not supported by modal views?

I am trying to open a modal view with a query param like:
<a data-rel="modalview" href="#myModalView?someParam=123" data-role="button">Open MV </a>
However when I click on the link/button I get this error:
Uncaught Error: Syntax error, unrecognized expression: #myModalView?someParam=123

Is this unsupported on Modal Views?

Mick
Top achievements
Rank 2
 answered on 26 Jun 2014
1 answer
145 views
Hello,

On select event of a panel bar item, I want to make an ajax call and set the content for sub item.

I started with the sample code as shown below. The issue is, it only sets the content for 1st item.

Thanks for your time and help.

--
Hiren

 <script id="resultstemplate" type="text/x-kendo-template">
       <ul id="resultsPanelBar">
           # for (var i = 0; i < data.length; i++) { #
                <li>#= data[i].name #<br/>#= data[i].addressLine1 #<br/>#= data[i].addressLine2 #, #= data[i].phone #
                                   <span style="display:none">|#= data[i].comprehensiveProviderId #</span>
                             <ul  id ="resultDetails"></ul>
                </li>
        # } #
       </ul>
    </script>    
function onSelect(e) {
        var selectedText = $(e.item).find("> .k-link").text();
        var splitSelectedText = selectedText.split('|');
        console.log("selectedText : " + selectedText);
                 console.log("Comprehensive Provider ID  : " + splitSelectedText[1]);
                
              $("#resultDetails").html("<li>"+splitSelectedText[1] +"</li>");
             }
               









Hiren
Top achievements
Rank 1
 answered on 26 Jun 2014
4 answers
217 views
Hi,

I am developing on Razor based ASP.NET MVC 5 web application using Visual Studio 2013. A partial view has a Kendo UI Grid and inside this grid there is a kendo ui autocomplete widget. Selection made from a dropdownlist populates this grid. The dropdownlist is outside the grid. I tried several ways including this one (http://www.telerik.com/forums/autocomplete-in-grid-column-samples-for-razor) but obviously it still didn't work in my case. 

The issue is that autocomplete is not working as it does not display the values which it suppose to show when typing inside the autocomplete. Below is the grid and autocomplete code in the partial view:

​ @(Html.Kendo().Grid(Model.Risks)
.Name("gridRisks")
.Columns(col =>
{
col.Bound(m => m.RiskID).Title("RiskID").Hidden();
col.Template(m=>{}).ClientTemplate(
Html.Kendo().AutoComplete()
.Filter("contains")
.Name("AutoCompleteRisks#=Risk#")
.DataTextField("Risk")
.BindTo(Model.AllAvailRisks)
.ToClientTemplate()
.ToHtmlString()
);
col.Command(c => c.Destroy());
})
.Pageable()
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Sortable()
.DataSource(d => d
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model => {
model.Id(r => r.RiskID);
model.Field(r=>r.Risk).Editable(true);
})
.Create("Editing_Create", "Builder")
.Read("Editing_Read", "Grid")
.Update("Editing_Update", "Builder")
.Destroy("Editing_Destroy", "Grid")
)
)

And I put the following javascript code inside an included javascript file:

function dataBound(e) {
this.element.find("script").appendTo(document.body);
}

The included javascript file (which contains the abvove javascript code) is added in the main view like this :

​@section Scripts {
<script src="@Url.Content("~/Scripts/Office/PDFInc.js")"></script>
}

Also importantly, the rendered HTML code for autocomplete is as follow. This rendered HTML already has all the required values (risk 1 through risk 7) which autocomplete should display when typing in the autocomplete space but even then it is not displaying these values which I think rendered correctly. 

<td role="gridcell"><input id="AutoCompleteRisks1" name="AutoCompleteRisks1" type="text"><script>
 jQuery(function(){jQuery("#AutoCompleteRisks1").kendoAutoComplete({"dataSource":[{"RiskID":5,"Risk":"risk 1"},{"RiskID":6,"Risk":"risk 2"},{"RiskID":7,"Risk":"risk 3"},{"RiskID":8,"Risk":"risk 4"},{"RiskID":9,"Risk":"risk 5"},{"RiskID":10,"Risk":"risk 6"}],"dataTextField":"Risk","filter":"risk 7"});});
</script></td>

I shall be thankful for help in resolution of this issue.

Thanks,
Habeeb
Top achievements
Rank 1
 answered on 26 Jun 2014
3 answers
646 views

I have a currency field set up on a KendoUI Grid like so:

DailyPriceChange: { type: 'number' },

It's column definition is as follows (as suggested by numerous other posts available here and elsewhere):
                {
                    title: 'Daily Price Change',
                    field: 'DailyPriceChange',
                    template: '#= IA.Kendo.Renderers.renderCurrency(DailyPriceChange) #',
                    attributes: { 'class': 'numeric' },
                    sortable: {
                        compare: function(a, b) {
                            return a === b ? 0 : ((a > b) ? 1 : -1);
                        }
                    }
                }

As an aside, the columns for the grid are actually built up in a private function that is used to set the .columns property on the datasource. The template just adds some formatting, and is not of course the underlying value that is being sorted.

My issue is that with or without the custom sortable function object, the data does not sort ASC correctly in IE9+ or FireFox (even recent), but does quite well in Chrome (any recent version). I would like to debug into the custom sortable object in Chrome Developer Tools, but a breakpoint on the compare function body is never hit when sorting, which makes me wonder if the code is even being executed. I even tried adding an alert() inside the function, but it is never seen. However, I can see the function definition when I examine the sortable property of the column in Developer Tools.

I have made a work-around to set all null values to 0 when the data is fetched (by using the parse override in the fields spec), but that not acceptable to the user community. 
Petur Subev
Telerik team
 answered on 26 Jun 2014
3 answers
470 views
Hi,

This thread is different than my previous post. I am working on asp.net mvc5 razor based web application using visual studio 2013. The partial view has a kendo grid and inside this grid there is an autocomplete widget. The autocomplete should also display default value bound to it when the webpage is loaded. However the autocomplete is neither displaying any default value nor when typed in it . However clicking two times (first click outside the autocomplete box but with in the same grid cell display the default bound value and then second click anywhere on the webpage enable the autocomplete functionality) enable the autocomplete functionality. Here is the code for Grid and Autocomplete:

@(Html.Kendo().Grid(Model.Risks)
.Name("gridRisks")
.Columns(col =>
{
col.Bound(m => m.RiskID).Title("RiskID").Hidden();
col.Bound(m => m.Risk).Title("Risk(s)").ClientTemplate(
Html.Kendo().AutoComplete()
.Filter("contains")
.Name("AutoCompleteRisks#=Risk#")
.DataTextField("Risk")
.BindTo(Model.AllAvailRisks)
.ToClientTemplate()
.ToHtmlString()
);
col.Command(c => c.Destroy());
})
.Pageable()
.ToolBar(toolbar =>
{
toolbar.Create();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Sortable()
.DataSource(d => d
.Ajax()
.Batch(true)
.ServerOperation(false)
.Model(model => {
model.Id(r => r.RiskID);
model.Field(r=>r.Risk).Editable(true);
})
.Create("Editing_Create", "PDFBuilderKIDs")
.Read("Editing_Read", "Grid")
.Update("Editing_Update", "PDFBuilderKIDs")
.Destroy("Editing_Destroy", "Grid")
)
)

Here is the rendered HTML (before those two clicks) for the autocomplete in the grid cell:

<td role="gridcell"><input id="AutoCompleteRisks1" name="AutoCompleteRisks1" type="text"><script>
 jQuery(function(){jQuery("#AutoCompleteRisks1").kendoAutoComplete({"dataSource":[{"RiskID":5,"Risk":"risk 1"},{"RiskID":6,"Risk":"risk 2"},{"RiskID":7,"Risk":"risk 3"},{"RiskID":8,"Risk":"risk 4"},{"RiskID":9,"Risk":"risk 5"},{"RiskID":10,"Risk":"risk 6"}],"dataTextField":"Risk","filter":"contains"});});
</script></td>

Here is the rendered HTML (after those two clicks) for the autocomplete in the grid cell:

<td role="gridcell" class="" data-role="editable"><span tabindex="-1" role="presentation" class="k-widget k-autocomplete k-header k-state-default k-state-hover"><input id="AutoCompleteRisks1" name="AutoCompleteRisks1" type="text" data-role="autocomplete" style="width: 100%;" class="k-input" autocomplete="off" role="textbox" aria-haspopup="true" aria-disabled="false" aria-readonly="false" aria-owns="AutoCompleteRisks1_listbox" aria-autocomplete="list"><span class="k-icon k-loading" style="display:none"></span></span><script>
 jQuery(function(){jQuery("#AutoCompleteRisks1").kendoAutoComplete({"dataSource":[{"RiskID":5,"Risk":"risk 1"},{"RiskID":6,"Risk":"risk 2"},{"RiskID":7,"Risk":"risk 3"},{"RiskID":8,"Risk":"risk 4"},{"RiskID":9,"Risk":"risk 5"},{"RiskID":10,"Risk":"risk 6"}],"dataTextField":"Risk","filter":"contains"});});
</script></td>


Thanks and will be obliged for resolution of this strange issue. I have also attached a screenshot.
Kiril Nikolov
Telerik team
 answered on 26 Jun 2014
3 answers
252 views
My mobile listview worked correctly when I had my datasource embedded in the JS on the page, but when I tested using the exact same dataSource on a seperate json file the application breaks saying "Uncaught TypeError: Cannot read property 'type' of undefined" in the Simulator debugger.
Here is the html
01.<!--Workshops page-->
02.<div data-title="Workshops" data-role="view" data-source="groupedData" id="listview-templates" data-init="workshopListViewTemplatesInit">
03.    <header data-role="header">
04.           <div data-role="navbar">
05.            <a href="#"  data-rel="back" data-align="left" data-icon="arrow-w" data-transition="slide">Back</a>
06.                <span data-role="view-title"></span>
07.            </div>
08.    </header>
09.    <ul id="custom-listview"></ul>
10.</div>
11. 
12.<script type="text/x-kendo-template" id="workshopListViewTemplate">
13.    <h3 class="item-title">#:name# <u>#:time#</u> Room #:room#</h3>
14.    <p class="item-info">#:title#</p><br>
15.    <p class="item-info2">*#:track#* #:code#</p>
16.    <!--MAY WANT TO ADD A VIBRATE ALERT FOR THE APP-->
17.    <!--<a data-role="button" class="details-link">Alert Me</a>-->
18.</script>



And here is my Javascript
01.<script>
02.function workshopListViewTemplatesInit() {
03.    var groupedData = new kendo.data.DataSource ({
04.        transport: {
05.             read: {
06.                url: "workshops.json",
07.                dataType: "json"
08.            }
09.        }
10.    });
11.    $("#custom-listview").kendoMobileListView({
12.        dataSource: kendo.data.DataSource({
13.            data: groupedData,
14.            group: "day",
15.        }),
16.    template: $("#workshopListViewTemplate").html(),
17.    headerTemplate: "<h2>#:(value)#</h2>"
18.    });
19.}
20.</script>
1.<script>
2.    var app = new kendo.mobile.Application(document.body);
3.</script>



Here is the JSON File:
01.[
02.  {
03.    "name":"Ben Lee",
04.    "title":"Preaching to the Whole Brain: Why the Right-Brain Can No Longer Be Ignored",
05.    "track":"UCRO: Intentional Leadership Development",
06.    "day":"2/22/2014",
07.    "time":"11:00am - noon",
08.    "room":"208",
09.    "code":"1"
10.  },
11.  {
12.    "name":"Phil Fuller",
13.    "title":"Steps toward Longevity in Ministry",
14.    "track":"UCRO: Intentional Leadership Development",
15.    "day":"2/22/2014",
16.    "time":"11:00am - noon",
17.    "room":"210",
18.    "code":"2"
19.  }
20.]


I have tried several different things and have gotten errors all revolving around "uncaught TypeError" and I can't figure out what I am doing wrong. Please help.

P.S I did have kendo.parseDate() for the "day" and then I used kendo.toString() to set the template title to be the Month and day and that all worked fine with the embedded dataSource as well. I took it off for this question.
Kiril Nikolov
Telerik team
 answered on 26 Jun 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?