Creating a Unique Window Design with List View Component in Kendo UI

I am trying to create a customized Kendo Window with two Kendo List Views, an Add button, and a Remove button inside. Right now, my main goal is to display a list of data in the List view within the Kendo Window.

Below is the JavaScript code I have:

            //retrieve template window
            var detailsTemplate = kendo.template($("#template").html());

            //create Kendo Window
            $("#contractDetail").kendoWindow({
                  title: "Edit Contract List",
                  modal: true,
                  visible: false,
                  resizable: false,
                  actions: ["Close"],
                  width: 800
            });

            //get data=[{"id":"1","subPhase":"Sub1"},{"id":"2","subPhase":"Sub2"}]
            $.ajax({
                dataType : "json", async: false,
                url : "/lah/getIntermediaryParameter"}).done(function(data) {
                    groupContracts = data;
            }); 

            //click button to openModal
            $("#openModalContract").click(function () {
                 $("#contractDetail").parent().css("top", "0px"); //adjust position
                 $("#contractDetail").parent().css("left", "0px"); //adjust position
                 $("#contractDetail").data("kendoWindow").open();
                 $("#contractDetail").data("kendoWindow").content(detailsTemplate(groupContracts)); //load template
                 $("#contractDetail").data("kendoWindow").center(); //center the window
                 $("#sortable-listC").kendoListView({
                      dataSource: {
                          data: groupContracts
                      }
                      template: kendo.template($("#myTemplate").html()) //get <li> template
                 });

                 $("#sortable-listC").kendoSortable({
                     connectWith: "#sortable-listD" //for drag and drop functionality
                 });

                 $("#sortable-listD").kendoSortable({
                     connectWith: "#sortable-listC" //for drag and drop functionality
                 });

            });

            //attempted to create custom close button, but unsuccessful
            $('#contractDetail').data().kendoWindow.bind('refresh',function(e){
                var win = this;
                $("#closeButtonModal").click(function(){
                     $("#contractDetail").data("kendoWindow").close();
                })
            })

This is My Template:

<script type="text/x-kendo-template" id="myTemplate">
        <li>#: subPhase #</li>
</script>
<script type="text/x-kendo-template" id="template">
    <div id="details-container" class="row" data-role="view" data-reload="true">
        <div id="contractListLeft" class="contractList col-xs-12 col-sm-12 col-md-3 col-lg-4">
            <ul id="sortable-listC" style="min-height: 110px; margin: 0; padding: 0;" data-role="sortable">
                //loop through list data here
            </ul>
        </div>
        <div class="col-xs-12 col-sm-12 col-md-3 col-lg-4">
            <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center" style="align:center;">
                <button class="btn" onclick="addGroup()">Add</button>
            </div>
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center" style="align:center;">
            &nbsp;
        </div>
        <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center" style="align:center;">
            <button class="btn" onclick="removeGroup()">Remove</button>
        </div>
        </div>
        <div id="contractListRight"  class="contractList col-xs-12 col-sm-12 col-md-3 col-lg-4">
            <ul id="sortable-listD" style="min-height: 110px; margin: 0; padding: 0;" data-role="sortable">
                //list data added when "addGroup" button clicked 
            </ul>
        </div>
    </div>
    <div class="row">
        <div class="col-xs-10 col-md-10 col-sm-10 col-lg-10">&nbsp;</div>
        <div class="col-xs-1 col-md-1 col-sm-1 col-lg-1">
            <a class="k-window-action k-link" href="\\#"><span class="">Close</span></a>
        </div>
    </div>   
</script>

I am struggling to display the GroupContracts list in the Kendo Window as it does not show any data. Upon checking console.log(), I noticed that there are multiple objects present. How can I effectively combine Kendo Window and Kendo List View?

Answer №1

[UPDATED]: Here is a sample code snippet to incorporate all your widgets in both JavaScript and HTML:

Feel free to create something similar to this.

var myWindow = $('#detailView').kendoWindow({
    width: 600,
    height: 450,
// add your configurations here
    open: function() {

// initialize your widgets within the window like:
 $("#sortable-listA").kendoListView({
                  dataSource: {
                      data: itemDetails
                  }
                  template: kendo.template($("#myTemplate").html()) //retrieve template <li>
             });

             $("#sortable-listA").kendoSortable({
                 connectWith: "#sortable-listB" //for drag and drop functionality
             });

             $("#sortable-listB").kendoSortable({
                 connectWith: "#sortable-listA" //for drag and drop functionality
             });
    }
});

//then display the window
myWindow.open();

Your template should resemble this:

 <div id="detailView">
        <div id="items-container" class="row" data-role="view" data-reload="true">
    <div id="itemListLeft" class="itemList col-xs-12 col-sm-12 col-md-3 col-lg-4">
        <ul id="sortable-listA" style="min-height: 120px; margin: 0; padding: 0;" data-role="sortable">
            //populate list items here
        </ul>
    </div>
    <div class="col-xs-12 col-sm-12 col-md-3 col-lg-4">
        <div class="text-center" style="align:center;">
            <button class="btn" onclick="addItem()">Add</button>
        </div>
    <div class="text-center" style="align:center;">
        &nbsp;
    </div>
    <div class="text-center" style="align:center;">
        <button class="btn" onclick="removeItem()">Remove</button>
    </div>
    </div>
    <div id="itemListRight"  class="itemList col-xs-12 col-sm-12 col-md-3 col-lg-4">
        <ul id="sortable-listB" style="min-height: 120px; margin: 0; padding: 0;" data-role="sortable">
            //list of items added when "addItem" button is clicked 
        </ul>
    </div>
</div>
<div class="row">
    <div class="col-xs-10 col-md-10 col-sm-10 col-lg-10">&nbsp;</div>
    <div class="col-xs-1 col-md-1 col-sm-1 col-lg-1">
        <a class="k-window-action k-link" href="\\#"><span class="">Close Window</span></a>
    </div>
</div>   
</div>

This is just a demonstration, I hope you find it beneficial.

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

Utilize jQueryUI sortable to serialize a list item within an unordered list

I'm looking to learn how to generate a JSON or serialize from a ul element with nested list items. Here's an example: <ul class="menu send ui-sortable"> <li id="pageid_1" class="ui-sortable-handle">Inscription <ul class="menu ...

Using static methods within a static class to achieve method overloading in Typescript

I have a TypeScript static class that converts key-value pairs to strings. The values can be boolean, number, or string, but I want them all to end up as strings with specific implementations. [{ key: "key1", value: false }, { key: "key2&qu ...

Tips for updating a specific portion of a component in react.js

import React,{useEffect} from 'react'; import CloudTables from '@cloudtables/react'; import { useState } from 'react'; function DataGridTable ({ input1Value, input2Value }) { return ( <div className="con ...

Guidelines for Sorting Objects and Arrays in a JavaScript Array

I have a set of data that needs to be filtered based on specific parameters. While I can successfully filter through the initial value in the array, I am struggling to filter deeper into nested arrays. The dataset is structured as follows: let data = [ ...

Mysterious dual invocation of setState function in React

My component is designed to display a list of todos like: const todosData = [ { id: 1, text: "Take out the trash", completed: true }, { id: 2, text: "Grocery shopping", completed: false }, ]; ...

Blank advertisements displayed on WordPress due to Google AdSense malfunction

My website on Wordpress can be found at . I encountered issues with the deprecated Adsense plugin for WordPress, so I created my own Adsense account. After verifying my site, I created a new ad unit and inserted its code into the body tag. The code for my ...

Trouble connecting an event to a dynamically added button using jQuery

I am currently working on a project that involves creating a dynamic walk-through wizard for users. The code I have developed adds an overlay to the page and generates a container with next and previous buttons. By utilizing Ajax, I populate the container ...

Obtain a selection of CSS classes from various CSS files to show in a dropdown menu

Is it feasible to extract CSS classes from several CSS files and showcase them in a dropdown menu? Can a list of classes be directly obtained from a CSS file in this manner? ...

Vue.js isn't triggering the 'created' method as expected

I have a main component called App.vue. Within this component, I have defined the created method in my methods object. However, I am noticing that this method is never being executed. <template> <div id="app"> <Header /> <Ad ...

How to upload files using Angular 4

Having some trouble trying to upload a file using angular 4, even after closely following a tutorial. I'm not sure where I might be going wrong, so any help in spotting the issue would be greatly appreciated. Here is the code snippet: import { Comp ...

What could be causing the error with firebase Sign In in next.js?

I set up a sign in page to enter email and password for Firebase authentication. The sign up process works fine, but I'm encountering an issue with the sign in functionality. 'use client' import { useState } from 'react'; import { ...

Customizing next.js _error page with i18n localization

Looking to create a customized error page for my Next.js project. I've been using the getServerSideProps method to localize my other pages, but I'm running into issues with translating strings on the _error page. I attempted to use the getStaticP ...

Making sure the checkbox stays selected in an angular environment

After experimenting with Angular 9 and a custom input, I achieved the following result => https://stackblitz.com/edit/angular-ivy-rgsatp My goal was to prevent users from disabling a radio button that is currently checked. Therefore, I made changes in ...

What is the best way to create a list from a matrix using JavaScript?

I have an array structured as follows: const input_array= [ ["red", "green"], ["small", "medium"], ["x", "y", "z"] //... can have any number of rows added dynamically ...

Asynchronously retrieving results in MongoDB

My task involves fetching all users from the users collection. app.post('/login', function(req,res,next){ users = self._db.get('users', {}) }) Below is the function in my database class: this.get = function( col, opt ) { ...

Using JavaScript includes to verify the presence of various values

let colorSet = ["black", "red", "pink", ]; This is the colorSet array. I can easily check if a specific value is present in the colorSet array. For example, to check if "red" is present in the array, I can use the following code: let isRedPresent = color ...

Enhancing progress through cleanliness

When developing a website, I am implementing progressive enhancement to ensure accessibility and SEO friendliness. This approach involves structuring elements like the menu and slideshow as unordered lists in the page markup, with JavaScript handling the s ...

Arranging an array of objects based on dual criteria

Sorting an array of objects based on 2 conditions is my current challenge First, I need to sort by value If the names are the same, I want to display them next to each other in ascending order of their values For a visual example, check out this demo: ht ...

Tips on maintaining the parent's scope in CoffeeScript while making an AJAX call

I need to iterate through an object in CoffeeScript and make an AJAX call for each item in the object using jQuery. However, I'm facing an issue with losing the reference to the initial context in the callback function of the AJAX call. The context al ...

Dynamically updating fields in PHP using jQuery's passed variable

In my web application, I have a selection of locker numbers available in a dropdown list that is populated from MYSQL/PHP. My goal is to display each locker's combination and location when a user selects a locker number from the dropdown list on the s ...