Telerik Forums
Kendo UI for jQuery Forum
1 answer
138 views

 

text should be above

 

Neli
Telerik team
 answered on 24 Jan 2023
2 answers
4.3K+ views

Hi,

i have a dropdown. When the value is set in open event, the value is selected only for the first 16 items (depending on itemHeight in virtual). How do I get the value to always be selected and automatically scroll to the selected value? Below you'll find a running example.

Thanks for your help.


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Kendo UI Snippet</title>

    
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2022.3.1109/styles/kendo.default-ocean-blue.min.css">
    
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2022.3.1109/js/jszip.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2022.3.1109/js/kendo.all.min.js"></script>
</head>
<body>

    <div id="example">
        <div id="grid"></div>
    </div>
    <br>
    <br>
    <br>
  <div id="container">
    <input id="dropdownlist" style="width:300px" />
  </div>


  <script id="templateDDL" type="text/x-kendo-template">
    <span>
      <table>
        <tr class="combo-tr">
            <td class="combo-td">${id}</td>
            <td class="combo-td">${name}</td>
            <td class="combo-td">${description}</td>
        </tr>
    </table>
    </span>
  </script>


<script>
    const maxRecords = 10000;
    let data = [];
    
    class MyData{}  

    function generateData(){
        
        for (let i = 1; i <= maxRecords; i++) {
            let myData = new MyData();

            myData.id = i;
            myData.name = "name" + i;
            myData.description = "description" + i;
            
            data.push(myData);
        }   
    }
    
    generateData();

    $(document).ready(function(){
        $("#grid").kendoGrid({
            dataSource: {
                data: data,
                schema: {
                    model: {
                        fields: {
                            id: {type: "integer"},
                            name: { type: "string" },
                            description: { type: "string" }
                        }
                    }
                },
                pageSize: 25,
                serverPaging: false,
            },
            height: 600,
            sortable: true,
            filterable: true,
            selectable: true,
            pageable: {
                previousNext:   true,    
                numeric:        true,
                buttonCount: 3,
            },
            columns: [
                { field: "id", title: "ID", width: "130px" },    
                { field: "name", title: "Name", width: "130px" },
                { field: "description", title: "Description", width: "130px" }
            ],
            filterable: false,
            scrollable: {
                virtual: false
            },
            change: function(e) {
                        changeDdl();
            },
            dataBound: function(e) {
                this.select("tr:eq(0)");
                this.content.scrollTop(0);
            }
        });

        $("#dropdownlist").kendoDropDownList({
            optionLabel: "-- Please select something --",
            width:300,
            size:"small",
            dataSource: data,
            dataTextField: "name",
            dataValueField: "name",
            template: kendo.template($("#templateDDL").html()), 
            serverPaging: true,
            virtual: {
                itemHeight: 50,
                valueMapper: function(options) {
                    $.ajax({
                        dataSource: data,
                        type: "GET",
                        dataType: "json",
                        data: convertValues(options.value),
                        success: function (data) {
                            options.success(data);
                        }
                    })
                },
            },
            open: function(e){
                const ddl_element = $("#dropdownlist").data("kendoDropDownList");
                // read the current value of ddl (startValue), comes from SetDdlValue
                const startValue = ddl_element.text();
                    
                ddl_element.setDataSource(data);

                // looking for startValue in ddl-dataSource
                const itemEqualToStartValue = ddl_element.dataSource.data().find(x=>x.name === startValue);

                // set value of ddl_element, that is equal to the startValue
                ddl_element.value(itemEqualToStartValue.name);
                ddl_element.trigger("change");
            },
            change: function(e){
            }
        });

        
        // set the DDL value for the first time 
        const grid = $("#grid").data("kendoGrid");
        const selectedItem = grid.dataItem(grid.select());
        
        const ddl_element = $("#dropdownlist").data("kendoDropDownList"); 
        SetDdlValue(ddl_element, selectedItem);
        
        function convertValues(value) {
            let data = {};
            value = $.isArray(value) ? value : [value];
            
            for (let idx = 0; idx < value.length; idx++) {
                data["values[" + idx + "]"] = value[idx];
            }
            return data;
        }
          
        // gets called when change in grid is called
        function changeDdl(){
            const grid = $("#grid").data("kendoGrid");
            const selectedItem = grid.dataItem(grid.select());
            
            const ddl_element = $("#dropdownlist").data("kendoDropDownList"); 
            SetDdlValue(ddl_element, selectedItem);
        }        

        function SetDdlValue(ddl_element, ddl_value) {      
            let TempDDS = [];
            let TempJson = { "id": ddl_value.id, "name": ddl_value.name, "description": ""};
            TempDDS.push(TempJson);
            ddl_element.setDataSource(TempDDS);
            ddl_element.value(ddl_value.name);
            ddl_element.trigger("change");
        }
    });
</script>
</body>
</html>

Neli
Telerik team
 answered on 24 Jan 2023
2 answers
147 views

hello.

url:
https://demos.telerik.com/kendo-ui/spreadsheet/datasource
I developed a program by applying this page and I am using it well.

However, if there is a lot of transmission data when trying "SAVE DATA CHANGES", an error occurs. It is not an error that occurs in the target url, but an error that cannot reach the target url itself.

All the data from the above url
vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
If I change it to , and save it, I get an error.

 

 

method : get

Because it is a get, an error will occur.
On my site, I get an error even though I tried to post.

 

 

It's not even that the size of the data to be transferred is large.
Moreover, an error occurs even though it is not a get but a post.
The number of data passed is not large.
This is not an error occurring in the target url, but the transmission itself has failed.

What are the countermeasures? What are the alternatives?
It's not big data, but I get an error at "SAVE DATA CHANGES".
What could be the workaround?


please solve it thank you


 

 

onplatform
Top achievements
Rank 1
Iron
 answered on 24 Jan 2023
1 answer
251 views

Hi,

I have been using kendo ui charts, and in one of pages I have fixed limited space for whole chart area (chart + legend).

Unfortunately, sometimes, dataset for this chart has a lot of elements (30-50) and legend is simply too big (regardless of position, it doesn't fit together with chart in designated space). 

Is there a way to customize legend (to limit its area and have only that area with scrollbar (if I put it right or left), or can I load legend elements in dropdown, so it can be extended if needed?

Any suggestions how to handle this?

Thank you

Regards,

Vedad

Nikolay
Telerik team
 answered on 19 Jan 2023
1 answer
266 views

Hello, 

I have strong performance problems with the ListBox when working with 10,000+ records. On the one hand, it takes a very long to display the data, on the other hand, the search takes a very long time if you have a lot of hits. It also takes a very long time to delete the searched word. Drag and drop is also very slow. Is there any way to improve the performance? The version I am using is from late 2020!

For example, when searching for "name5" it takes a long time to display the results, when deleting "name5" from the search box the performance is also poor.
Here I use only 2 listboxes, in my project I need 3, which makes the performance even worse.

Just for your information, I actually do not generate the data locally it's just for this example to generate enough datasets.

Thanks for your help.


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="https://kendo.cdn.telerik.com/2022.3.1109/styles/kendo.default-ocean-blue.min.css">
    
    <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2022.3.1109/js/jszip.min.js"></script>
    <script src="https://kendo.cdn.telerik.com/2022.3.1109/js/kendo.all.min.js"></script>

    <title>Kendo Listbox</title>
</head>
<body>
    <script id="listbox_template" type="text/kendo-x-tmpl">                                          
        <div>                                                                                         
            <table class="listbox_trueberschrift" style="width:100%;">                                 
                <colgroup>                                                                            
                    <col style="width:140px;">                                                         
                    <col style="width:180px;">                                                         
                </colgroup>                                                                            
                <tr style="display:none;">                                                            
                    <td class="listbox_tdueberschrift" nowrap>Code</td>                                
                    <td class="listbox_tdueberschrift" nowrap>Beschreibung</td>                        
                </tr>                                                                                  
                <tr>                                                                                   
                    <td nowrap>#:OrderID#</td>                                                         
                    <td nowrap>#:ShipName#</td>                                                         
                </tr>                                                                                  
            </table>                                                                                   
        </div>                                                                                         
    </script>

    <div id="example" role="application">
        <div class="demo-section wide">
            <input type='text' id='searchBox' class='k-input k-textbox k-input-solid k-input-md k-rounded-md' placeholder='Suchen' />
        <div>
            <select id="listbox1"></select>
            <select id="listbox2"></select>
        </div>
    </div>
        <script>
            const maxRecords = 10000;
            let dataSource2 = [];
            let dataSource3 = [];
            
            class MyData{}

            function generateData(){
                for (let i = 1; i <= maxRecords; i++) {
                    let myData = new MyData();

                    myData.OrderID = i;
                    myData.ShipName = "ShipName" + i;
                    
                    if(i <= 5000) dataSource2.push(myData);
                    else dataSource3.push(myData);
                } 
            };

            generateData();
            
            $(document).ready(function () {
                $("#searchBox").on("input",function(e) {
                    var listBox1 = $("#listbox1").getKendoListBox();
                    var listBox2 = $("#listbox2").getKendoListBox();
                    var sarchString = $(this).val();

                    listBox1.dataSource.filter({ field: "ShipName", operator: "contains", value: sarchString });
                    listBox2.dataSource.filter({ field: "ShipName", operator: "contains", value: sarchString });
                });

                $("#listbox1").kendoListBox({
                    connectWith: "test",
                    draggable: true,
                    dropSources: ["listbox2"],
                    selectable: "multiple",
                    dataSource: dataSource2,
                    dataTextField: "ShipName",
                    dataValueField: "OrderID",
                    template: kendo.template($("#listbox_template").html()),
                    toolbar: {
                        tools: ["moveUp", "moveDown", "transferTo", "transferFrom", "transferAllTo", "transferAllFrom", "remove"]
                    }                                                                                    
                });
                
                $("#listbox2").kendoListBox({
                    draggable: true,
                    dropSources: ["listbox1"],
                    dataSource: dataSource3,
                    selectable: "multiple",
                    dataTextField: "ShipName",
                    dataValueField: "OrderID",
                    template: kendo.template($("#listbox_template").html()),
                });
            });
        </script>
    </div>
    
    <style>
        .demo-section label {
            margin-bottom: 5px;
            font-weight: bold;
            display: inline-block;
        }
    
        #example .demo-section {
            max-width: none;
            width: 600px;
        }
    
        #example .k-listbox {
            width: 236px;
            height: 350px;
        }
    
        #example .k-listbox:first-of-type {
            width: 270px;
            margin-right: 1px;
        }
    </style>
</body>
</html>

Nikolay
Telerik team
 answered on 19 Jan 2023
2 answers
1.4K+ views

Hi, 

The menu widget has an 'enable()' function, is there a similar way to hide a menu item the same way?

Thanks,
Grant

Khaled
Top achievements
Rank 1
Iron
 updated answer on 18 Jan 2023
0 answers
158 views

Hello, 

I'm trying to combine custom positions of shape connectors with the save and load functionality.  I've combined the following two examples in the dojo:

https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/diagram/configuration/shapes.connectors.position 

https://docs.telerik.com/kendo-ui/api/javascript/dataviz/ui/diagram/methods/load

Dojo example: https://dojo.telerik.com/oqAloqOY/2 

As you can see after loading the saved model the custom connectors are gone. Is there any way to persist them or at least re-apply them after load?

Thanks

The Cowboy
Top achievements
Rank 1
 asked on 17 Jan 2023
1 answer
459 views

I am trying to move away from using select2 multi-select. Ideally, I would like to call a function that returns the value for the kendo multi-select during initialization. The value will be retrieved by an AJAX call. Is there any way I could implement this? I tried using dataBound, but it looks like anything inside the data-bound will be called every time user clicks on the multi-select control. 

During initialization, I don't want to call the dataSource. This will be updated every time user clicks open. I just need to update the value field based on the AJAX result.
$("#multiselect").kendoMultiSelect({
  dataSource: {
    transport: {
      read: {
        url: "https://demos.telerik.com/kendo-ui/service/products",
        dataType: "jsonp"
      }
    }
  },
  open: function(e){
    // datasource is dynamic and should be updated with every click.
    $('#multiselect').data('kendoMultiSelect').dataSource.read();
  },
  dataTextField: "ProductName",
  dataValueField: "ProductID",
  autoBind: false,
  value: "IS IT POSSIBLE TO GET DATA FROM AJAX DURING INITIALIZATION?"
});
Is this possible with telerik multiselect?
Martin
Telerik team
 answered on 17 Jan 2023
1 answer
149 views

The documentation for ScrollView autoBind is incorrect or incomplete.  When examining the ScrollView autoBind API Reference the sample configuration does not mention or show proper usage of the autoBind configuration.  Additionally, I am unable to get the ScrollView widget to initialize when setting autoBind: false

When using this configuration the widget does not initialize.  If I set autoBind: true the widget binds to the dataSource but it does not honor the current query parameters. 

This code runs correctly when autoBind: true.  It fails when autoBind: false  Dojo Snippet

<script id="scrollview-template" type="text/x-kendo-template">
    <div style="width: 200px; height: 200px; background-image: #=setBackground(data.filename)#; background-repeat:no-repeat; background-size: cover;"></div>
    <p>#= data.filename #</p>
</script>


<div id="container" style="margin: 20px;">
    <div id="scrollView"
      data-role="scrollview" 
      data-auto-bind="false"
      data-pageable="true"
      data-enable-pager="true"
      data-template="scrollview-template"
      data-bind="source: fruits"
      data-content-height="100%" 
      data-page="0"
      style="width: 400px; height: 300px; max-width: 100%;">
    </div>
</div>



<script>

function setBackground(filename) {
  return "url(https://demos.telerik.com/kendo-ui/content/shared/images/photos/" + filename + ")";
}

var viewModel = kendo.observable({
  fruits: new kendo.data.DataSource({
    data: [
      { filename: "15.jpg" },
      { filename: "16.jpg" },
      { filename: "17.jpg" }
    ],
    schema: {
      model: {
        fields: {
          filenname: { type: "string" }
        }
      }
    }
  })
});

$(document).ready(function() {
  kendo.bind($("#container"), viewModel);

  

  setTimeout(function(){
    console.log("ScrollView Next - Refresh");
    //var scrollView = $("#scrollView").kendoScrollView().data().kendoScrollView;
    //scrollView.scrollTo(1);
    //scrollView.refresh();
    }, 1000);
  });


</script>

Neli
Telerik team
 answered on 17 Jan 2023
0 answers
252 views

When utilizing an image editor control I receive the following output in console and the image does not load: Please see markup below

 

Html Page Div Implementation

Html Page Script Implementation

Console output

Result of View


My Layout has the following implementations for CSS and JS

Isaiah
Top achievements
Rank 1
 asked on 16 Jan 2023
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
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
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Bohdan
Top achievements
Rank 3
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Elliot
Top achievements
Rank 1
Iron
Iron
Iron
Sunil
Top achievements
Rank 1
Cynthia
Top achievements
Rank 1
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?