Kendo's comboBox for local virtualization

Looking to implement virtualization for local data using the kendo object ComboBox.

I've tried different methods, but only the current page (first 40 elements) is displayed.

I followed a code structure similar to the kendo virtualization tutorial and also experimented with utilizing the data field in Dasource while disabling ServerPaging, yet encountered issues.

Here's the HTML snippet:

<div class="col-xs-11 col-xs-offset-1">
<input kendo-combo-box="EndProdChangeDialogCtrl.comboMaterialTool1" style="width:100%;"
ng-disabled="EndProdChangeDialogCtrl.disabledTool1"
k-filter="'contains'"
k-data-text-field="'Description'"
k-data-value-field="'ToolCode'"
k-value-primitive="true"
k-height="520"
k-data-source="EndProdChangeDialogCtrl.kk"
k-ng-model="EndProdChangeDialogCtrl.SelectedObject.ToolCode1"
k-on-change="EndProdChangeDialogCtrl.ChangeTool(EndProdChangeDialogCtrl.isLinkedTool1,EndProdChangeDialogCtrl.positionTool1,EndProdChangeDialogCtrl.SelectedObject.ToolCode1)"
ng-class="{'required-tool':(EndProdChangeDialogCtrl.requiredTool1 == true && (EndProdChangeDialogCtrl.SelectedObject.ToolCode1==''||EndProdChangeDialogCtrl.SelectedObject.ToolCode1==null)),
'required-tool-ok':(EndProdChangeDialogCtrl.requiredTool1 == true && (EndProdChangeDialogCtrl.SelectedObject.ToolCode1!='' && EndProdChangeDialogCtrl.SelectedObject.ToolCode1!=null)) }" />

</div>

And here's the TypeScript file:

this.tools1List = t1.SuitableTools; //copy array for safe
var suits = new Array();
suits = suits.concat(t1.SuitableTools);

this.comboMaterialTool1.setOptions(<kendo.ui.ComboBoxOptions>{
virtual: //<kendo.ui.ComboBoxVirtual>
{
itemHeight: 52,
valueMapper: function (options) {
var tool = Enumerable.from(suits).firstOrDefault(i => i.ToolCode == options.value);
var index = suits.indexOf(tool);
options.success(index);
}
},
});

this.kk = new kendo.data.DataSource({
schema: {
model: {
fields: {
Description: { type: "string" },
ToolCode: { type: "string" },
IsAvailable: { type: "boolean" },
IsMountedOnThisMachine: { type: "boolean" },
TstCode: { type: "number" }
}
},
total: function (response) {
response.total = suits.length;
return response.total;
}
},
transport: {
read: function (options) {
var pagevalue = suits.slice(options.data.page * options.data.pageSize, options.data.page * options.data.pageSize + options.data.take);
options.success(pagevalue);
// options.success(suits);
},
},
pageSize: 40,
serverPaging: true,
// type: "odata" show nothing with odata type
});

Answer №1

After much searching, I stumbled upon a solution: by simply adding k-virtual="true" to the default settings in the HTML page, you can optimize performance.

If you're curious to learn more or see an example, check out this link:

In order to make things work smoothly, I also discovered that implementing a fake mapper that returns an empty array helps resolve potential issues.

Remember, it's essential for comboBox.value() to be associated with a specific model using k-ng-model.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the proper way to call document methods, like getElementByID, in a tsx file?

I am currently in the process of converting plain JavaScript files to TypeScript within a React application. However, I am facing an error with document when using methods like document.getElementById("login-username"). Can you guide me on how to referen ...

Issue encountered while trying to iterate through an observable: Object does not have the capability to utilize the 'forEach' property or method

I am currently following the pattern outlined in the hero.service.ts file, which can be found at this link: https://angular.io/docs/ts/latest/guide/server-communication.html The Observable documentation I referenced is available here: When examining my c ...

Sharing data between two Angular 2 component TypeScript files

I'm facing a scenario where I have two components that are not directly related as parent and child, but I need to transfer a value from component A to component B. For example: In src/abc/cde/uij/componentA.ts, there is a variable CustomerId = "sss ...

Applying ngStyle based on changing information

I am struggling with setting the fill and stroke of an SVG path element based on the values in an array named shirts. <path class="st2" style="stroke-width:2.0;" [ngStyle]="myStyle(4)" d="M11.5,315....315.9z"/> In my code, I have defined a function ...

Generic Typescript Placeholder Design

Imagine you have the following data: const dataA = { name: "John", age: 25, attributes: {specificA: "hello", specificA2: 14, nonspecific:"Well"}, } const dataB = { name: "Lisa", age: 38, attributes: {spe ...

Instructions for adding a new property dynamically when updating the draft using immer

When looking at the code snippet below, we encounter an error on line 2 stating Property 'newProperty' does not exist on type 'WritableDraft<MyObject>'. TS7053 // data is of type MyObject which until now has only a property myNum ...

Angular's ExpressionChangedAfterItHasBeenCheckedError is a common issue that developers encounter

This message continues the discussion about a persistent issue I have been facing. Here is the link to the original thread on Stack Overflow: stackoverflow.com/questions/44596418/angular-throws-expressionchangedafterithasbeencheckederror-with-textarea Af ...

Combining Angular with WordPress

I need to integrate an Angular ticket sales form onto the main page of my Wordpress site. What is the best method for accomplishing this? Should I consider using an iframe tag or are there other solutions that may be more effective? Thank you for your as ...

Exploring array data retrieval in Angular

I need to display various inch sizes for different bike models. I have a json file containing an array of bike data. [{ "name": "Mountainbike", "img_url": "assets/img/mountainbike.jpg", "mount_size": [{&quo ...

One can only iterate through the type 'HTMLCollection' by utilizing the '--downlevelIteration' flag or setting a '--target' of 'es2015' or above

I'm currently working on developing a loader for my static grid. I've incorporated the react-shimmer-skeleton package source code, but I'm encountering issues with eslint in strict mode. You can find the respective repository file by followi ...

I encountered the error message "The property you are trying to access does not exist on the type 'never'" while attempting to retrieve JSON data from the API response

Every time I attempt to access the fields in items such as id or title, an error pops up saying Property does not exist on type 'never'. Interestingly, when I log the data using console.log(response.data), everything seems to be working fine. I ...

What are the best ways to handle data using the .pipe() function?

Looking to optimize an Angular component Typescript function that returns an Observable<book[]>. The logic involves: If (data exists in sessionStorage) Then return it Else get it from remote API save it in sessionStorage return it End ...

Enhance React component props for a styled component element using TypeScript

Looking to enhance the properties of a React component in TypeScript to include standard HTML button attributes along with specific React features such as ref. My research suggests that React.HTMLProps is the ideal type for this purpose (since React.HTMLA ...

Issue with jsPDF: PNG file is either incomplete or corrupted

I'm encountering an issue while attempting to pass Image data to the addImage function. I have tried downgrading the versions of jspdf and html2canvas, as well as experimenting with different ways to import the two libraries, but the problem still per ...

Encountering a surprise token < while processing JSON with ASP.NET MVC alongside Angular

I encountered an issue when attempting to return the Index page. The data is successfully sent from the client to the server, but upon trying to display the Index page, an error occurs. Could someone review my code and identify where the mistake lies? acc ...

Angular enables the use of multiple instances of a service from the parent component to the child component

I recently came across this discussion: Utilizing multiple instances of the same service. Can one utilize multiple instances of a service from parent to children? For instance, imagine having an ElementService in the ParentComponent with 2 separate instan ...

I am looking to attach a Bootstrap 4 class to the form input field

I needed to apply the "is-invalid" bootstrap4 class when my Angular form field was invalid and touched. I attempted to achieve this with: <input type="text" #name class="form-control" [class.is-invalid]="name.invalid && name.touched" name="Name ...

Enable Parse5's case sensitivity

Recently, I've attempted to parse Angular Templates into AST using the powerful parse5 library. It seemed like the perfect solution, until I encountered an issue - while parsing HTML, it appears that the library transforms everything to lowercase. Fo ...

Dynamic Angular routes with varying numbers of parameters

I am working on developing an application where I need to associate TreeList navigation with routes. Consider the file structure in the explore section: - desktop - file1.txt - pictures - wallpaper - my-selfie.png - file2.txt - file4. ...

Tips for ensuring that an AngularJS2 textbox accommodates the input text adequately

Is it possible to create 3 HTML text boxes with an initial width of 30px each? If someone types more text than what can fit in one box, I would like all three boxes to expand their widths to match the size of the largest text box. What is the most effect ...