Telerik Forums
Kendo UI for jQuery Forum
1 answer
2.2K+ views

Hello

 

I have a dropdown list that, on change, populates a few other fields on a page.  This functionality works provided that it's taking place as a result of a user interaction.

 

I am trying to make the form data persistent between page refreshes.  I have captured the value of the selection in local storage, and populate it on page load using the methods described https://www.telerik.com/forums/how-do-you-set-the-value-of-a-dropdownlist-after-reading-external-data and in this JSFiddle.

 

However, on page load, the dropdown list has the correct selection, the change() event triggers, but fails to populate data.  The dataItem variable is null (I think) and I'm not clear why.

 

Any help is appreciated.  Relevant code below...

 

DropDownList widget

<div class="requisitionForm-content">
    @(Html.Kendo().DropDownListFor(m => m.RequisitionModel.FormDto.VendorIdentifier)
        .Events(e => e.Change("onVendorChange"))
        .OptionLabel("Select a vendor...")
        .DataValueField("Identifier")
        .DataTextField("Name")
        .Filter(FilterType.Contains)
        .DataSource(s => s.Read(r => r.Action("GetVendors", "RequisitionForm", new { formVendor = Model.RequisitionModel.FormDto.VendorIdentifier }).Type(HttpVerbs.Post).Data("getVendorExtraData")))
        .HtmlAttributes(new { style = "width:360px" }))
</div>

 

onVendorChange function:

function onVendorChange(e) {
    var phone = "";
    var address = "";
    var fax = "";
    var email = "";
 
    var vendorDropList = $('#RequisitionModel_FormDto_VendorIdentifier').data("kendoDropDownList");
    var dataItem = vendorDropList.dataItem();
 
    if (dataItem) {
        phone = dataItem.Phone ? dataItem.Phone : "";
        address = dataItem.Address ? dataItem.Address : "";
        fax = dataItem.Fax ? dataItem.Fax : "";
        email = dataItem.Email ? dataItem.Email : "";
 
        var requisitionList = $('#RequisitionModel_FormDto_RequisitionType').data("kendoDropDownList");
        var reqType = requisitionList.dataItem();
 
        if (dataItem.BlanketOrderPo &&
            reqType &&
            reqType.Identifier == "@RequisitionType.BlanketOrder.Identifier.ToString()") {
            $('#RequisitionModel_FormDto_PoNumber').val(dataItem.BlanketOrderPo);
        }
    }
 
    $('#RequisitionModel_FormDto_VendorContactPhone').val(phone);
    $('#RequisitionModel_FormDto_VendorAddress').val(address);
    $('#RequisitionModel_FormDto_VendorFax').val(fax);
    $('#RequisitionModel_FormDto_VendorEmail').val(email);
}

 

Page document.ready() to get data from local storage

var WipRequisition = localStorage.getItem(employeeGuid);
if (WipRequisition !== null) {
    var formObject = JSON.parse(WipRequisition);
    stringToForm(formObject, $("#requisitionFormForm"));
 
    // Now deal with the dropdown list elements.
    var kendoDropDownElements = [
        "RequisitionModel_FormDto_VendorIdentifier",
        "RequisitionModel_FormDto_RequisitionType",
        "RequisitionModel_FormDto_DeliveryLocationIdentifier",
        "RequisitionModel_JobIdentifier",
        "RequisitionModel_FormDto_CostCodeIdentifier",
        "RequisitionModel_FormDto_CurrencyIdentifier",
        "RequisitionModel_Officer1Identifier",
        "RequisitionModel_Officer2Identifier"
    ];
    for (var element in kendoDropDownElements) {
        $("#" + kendoDropDownElements[element]).data('kendoDropDownList').value(formObject[kendoDropDownElements[element]]);
        $("#" + kendoDropDownElements[element]).data('kendoDropDownList').trigger("change");
 
    }
}

 

Thanks in advance.

Neli
Telerik team
 answered on 12 Feb 2018
3 answers
4.7K+ views

 I'm simply too stupid for that. Why does the following not work?
Debugging the lines there the function is called without any error.

 

   <button class="k-button" id="myTextButton" type="button">Enable</button>

....

 

 <script>

  $(document).ready(function () {

    $("#myTextButton").click(function () {
                    ("#myTextButton").enable(true);
                    ("#myTextButton").value = "value text";
                    ("#myTextButton").text = "text text";
                    ("#myTextButton").html = "html text";
                    ("#myTextButton").innerHTML = "innerHTML text";
                });

</script>

David
Top achievements
Rank 1
Iron
 answered on 12 Feb 2018
2 answers
201 views
Hello,
              I have created for my problem  I want to  It is not running as expected
Ivan Danchev
Telerik team
 answered on 12 Feb 2018
2 answers
3.8K+ views
How to display horizontal grid lines in Kendo UI grid?

The following works...any  elegant way to do it?

                        var kendoGrid = $(grid).data("kendoGrid");
                        var dataSource = kendoGrid.dataSource.data();

                        $(grid).find('table[role="grid"]').each(function() {
                            $(this).css("border-collapse", "collapse");
                        });

                        $.each(dataSource, function(i, row) {
                            $('tr[data-uid="' + row.uid + '"]').css("border-bottom", "1pt solid black");
                        });

Thanks, Alon

Roby
Top achievements
Rank 1
 answered on 09 Feb 2018
1 answer
454 views

Hello,

I'm using a kendo scrollview for a web application with a local datasource populated by a call to a controller.  The data retrieval and feeding seems to be working properly and there is no issue there.

The issue I am having is making the scroll view look good.  It seems that when the scroll view renders that it renders all the pages and the width of my page becomes elongated.  If you scroll you see the other pages and their items.

We are trying to show users the latest creative they are able to order.  It will usually consist of at least 2 pages.

I tried to follow the demo as best as I could but I think the scrollview behaves different with a local datasource.  My markup is below as well as with the template.

$("#scrollview").kendoMobileScrollView({
                dataSource: creatives,
                itemsPerPage:4,
                contentHeight: "150px",
                //contentWidth: "400px",
                enablePager: false,
                template: kendo.template($("#template").html())
            });

            $("#prev-img").click(function (e) {
                var scrollView = $("#scrollview").data("kendoMobileScrollView");
                scrollView.prev();
            });

            $("#next-img").click(function (e) {
                var scrollView = $("#scrollview").data("kendoMobileScrollView");
                scrollView.next();
            });

***TEMPLATE***
<script id="template" type="text/x-kendo-template">

        @*<div data-role="page">*@
            #for (var i = 0; i < data.length; i++) { #
            <div style="float: left; display: table; border: solid; border-width: 1px; border-color: gray; margin: 2px; text-transform: uppercase;">
                <div style="padding:2px">
                    <a class="thumb thumbshow">
                        <img src="#= data[i].ImagePath #" style="width:150px;height:194px" alt="" onerror="this.src='@Url.Content("~/Content/images/No_Image_Available.png")'">

                    </a>
                </div>
                <div style="display:table-cell;vertical-align:top;padding-left:5px;height:215px; width:110px;padding-right:5px;position:relative">
                    <div style="font-weight:bold; margin-bottom:10px;margin-top:5px;">
                         #= data[i].Description#
                    </div>
                    <div style=" display: inline-block; overflow-y: hidden;  width:110px">
                        <div style=" display: inline-block; height: 215px; width:139px">
                            <div class="CreativeInventory" style="display: inline-block; padding-top: 4px; padding-bottom: 4px; padding-left: 4px; padding-right: 7px; margin-bottom: 4px; text-transform: none; ">
                                # for(var j=0; j < data[i].CreativeList.length; j++){ #
                                <p>&bull; #= data[i].CreativeList[j].Media #</p>
                                # } #

                                @*#= data[i].CreativeList[0].LongDescription #*@
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            #}#
        @*</div>*@
    </script>

I will also attach 2 images showing how the scrollview renders - mainview shows the first page of the scroll view and notice the window scroll bar at the bottom.  scrolledview shows the other pages which seem to be rendered far right of what should be the main viewing area.  The positioning of each of the items is weird too not sure if that is because of our styling or if it is related to my scrollview issues.

We ideally want to show 4 to 5 items per page next to each other and same sized boxes.

Thanks for your help.

 

Tsvetina
Telerik team
 answered on 09 Feb 2018
6 answers
612 views
Hi, I'm try to insert node in treeview like demo

this is my code

var treeviewData = $("#treeview").data("kendoTreeView");
var selectedNode = treeviewData.select();
treeviewData.append({text: Name}, selectedNode);

,but after insert at child node is undefined data

can I fix this problem
Ivan Danchev
Telerik team
 answered on 09 Feb 2018
3 answers
224 views

In Kendo UI for Angular 2 we have a custom filter (very similar to your provided example http://www.telerik.com/kendo-angular-ui/components/grid/filtering/reusable-filter/#toc-reusable-custom-filter-components), it works nicely,  but we get a compilation warning:

 export 'CompositeFilterDescriptor' was not found in '@progress/kendo-data-query'

 

Additionally would it not make sense to extend the base class BaseFilterCellComponent with properties 

@Input() public column: ColumnComponent;
@Input() public filter: CompositeFilterDescriptor;

as they are needed by all filters (also seen in your example in dropdownlist-filter.component.ts). so custom filter implementors dont need to add them. Decorators on properties are inherited now in Angular/typescript

Dimiter Topalov
Telerik team
 answered on 09 Feb 2018
3 answers
853 views

I am trying to set the max row count after I retrieved the data from AJAX call. The default option for the number of rows is 200. I am needing to be able to change this number based on the number of rows returned from AJAX call. I want the page to have to have the default of 200 when the page loads.

The user then chooses from a dropdown on the page to query the backend for data which will have a different number of rows each time. I was hoping to be able to just set the rows property on the sheet.options object, but it does not look like these values are re-read after initialization.

How should I do this? Especially if I am going to have multiple tabs of data with different number of rows.

Thanks.

Tim
Top achievements
Rank 1
 answered on 08 Feb 2018
3 answers
407 views
Is it possible to have onLabel and offLabel that is longer than three characters?  I'm using the mobile switch on a web page with the silver theme and it appears that if I make the labels more than three characters it bleeds over into the other label.  Try it out yourself click on the "Edit this sample" button here http://demos.telerik.com/kendo-ui/switch/adaptive and change the onLabel or offLabel to "XXXXXXXX" or something long and you will see what I'm talking about.  What I'm trying to accomplish is to get rid of the corresponding labels that you would put next to the control and just show that toggled text in the control itself.  For example I want a switch with the onLabel="Edit Mode" and offLabel="View Mode".
Stefan
Telerik team
 answered on 08 Feb 2018
1 answer
768 views

below is the kendo grid which is not calling the mentioned action/controller on page load hence the data to the grid is empty..

HTML Code

<div class="container-fluid">
        <div class="row">
            <div class="col-xs-18 col-md-12">
                @(Html.Kendo().Grid<abcxksdkd.Models.DisplayUserModel>
            ()
            .Name("grid")
            .Columns(columns =>
            {
                columns.Bound(p => p.UserName).Filterable(false);
                columns.Bound(p => p.UserRole);
                columns.Bound(p => p.Email);
                columns.Bound(p => p.isLocked);
            })
            .Pageable()
            .Sortable()
            .Scrollable()
            .Filterable()
            .HtmlAttributes(new { style = "height:550px;" })
            .DataSource(dataSource => dataSource
            .Ajax()
            .PageSize(20)
            .Read(read => read.Action("Orders_Read", "Admin"))
            )
                )
            </div>
        </div>
    </div>

 

CONTROLLER CODE

 

public ActionResult Orders_Read([DataSourceRequest]DataSourceRequest request)
        {
            Model user = new Model();
           
            foreach (var a in DbContext.Users)
            {
                user.UserName = a.Name;
                user.UserRole = Roles.ToString();
                user.isLocked = a.Lockout;
                user.Email = a.mail;
            }
            var result = Enumerable.Range(0, 10).Select(i => new Model
            {
                UserName = user.UserName,
                Email = user.Email,
                isLocked = user.isLocked,
                UserRole = user.UserRole
            });
            return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
        }

Stefan
Telerik team
 answered on 08 Feb 2018
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
ScrollView
Switch
TextArea
BulletChart
Licensing
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
FloatingActionButton
CircularGauge
ColorGradient
ColorPalette
DropDownButton
TimeDurationPicker
ToggleButton
ContextMenu
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
DateTimePicker
RadialGauge
ArcGauge
AICodingAssistant
SegmentedControl
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
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?