Kendo Grid is not compatible with Angularjs ng-click functionality

I am struggling to trigger a function when selecting a checkbox in a Kendo grid using AngularJS and Kendo grid. Surprisingly, I am not getting any response on click - no errors or logs either. I attempted placing console.log() at the beginning of the function being called but it did not show anything. I have experimented with placing the method both within a service in scope and directly in scope.

My main query revolves around how to effectively utilize ng-click on a checkbox embedded within a cell template of a Kendo grid?

Here is the code snippet for binding the grid:

var cols = this.GetGridColumns(uiConfig.GridColumns);

var grid = $("#kGrid").kendoGrid({
dataSource: {
   serverPaging: true,
   serverSorting: true,
   schema: {
         data: "data",
         total: "total",
         model: {
         id: "relatedEntityID"
         }
   },
   pageSize: 10,
   transport: {
   read: function(options) {
          // read from service 
       }
     }
   },
   columns: cols, 
   scrollable: false,
   pageable: { "refresh": true, "pageSizes": true },
   sortable: true,
   filterable: true,
   selectable: "multiple",
   change: () => this.onChange()
});

Below is the definition:

GetGridColumns(columns: Array<servicePath.SLF.solutionEngine.Model.Admin.GridColumn>): any
    {
        var colHeader = new Array();

        colHeader.push({
            template: '<input type="checkbox" id="cbItem" class="checkbox" ng-click="genericServices.selectRow(\'kGrid\', $event)" />',

            headerTemplate: '<input type="checkbox" id="check-all" ng-click="genericServices.ToggleCheckAllInGrid(\'#kGrid\', $event)" />',
            width: '30px'});

        var column = new servicePath.SLF.solutionEngine.Model.CMs.GridColumnCM();

        for (var j=0 ; j < columns.length; j++)
        {
            column = new servicePath.SLF.solutionEngine.Model.CMs.GridColumnCM();

            column.Field = columns[j].BindingName;
            column.Title = columns[j].BindingName;
            column.ColumnType = columns[j].GridColumnType;
            column.HorizontalAlignment = columns[j].HorizontalAlignment;
            column.LocalizedName = columns[j].LocalizedLabel;

            colHeader.push({ title: column.Name, field: columns[j].BindingName, template: column.Template } );
        }

        return colHeader;
    }

The function genericServices.ToggleCheckAllInGrid used in the header template appears to be functioning correctly within the above code.

This is the definition of genericServices.

this.selectRow = function (gridId: string, e: any): void {
            gridId = '#' + gridId;
            console.log(gridId);

            var elem = angular.element(e.currentTarget);
            var row = elem.closest("tr");
            var checked = elem.prop('checked');

            if (checked) {
                //-select the row
                row.addClass("k-state-selected");
            } else {
                //-remove selection
                row.removeClass("k-state-selected");
            }
        };

Answer №1

It seems like the angular bootstrap function is running before the rows are actually added to the grid (in the Document Object Model).

If this is the case, you may need to trigger the angular bootstrap manually.

Answer №2

If you want to manage the onclick event on a kendo grid header, you can do so by using the code snippet below:

$('body ').on('click','.grid .k-header',function(e){

 //add your custom logic here..
});

It's important to note that in kendo grid, ng-click or onClick events cannot be used. Only href will be effective.

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

Obtain a compilation of items present in every tier of nesting

{ "Alice Smith": { "Age": 20, "Gender": "F" }, "Bob Johnson": { "Age": 22, "Gender": "M" }, "Eve Michaels":{ "Age": 25, "Gender": "F" } } Can someone assist me in obtaining an array w ...

Searching to loop through JSON within a Sequelize / Postgres database query in order to identify a corresponding value

Hello everyone, I'm new here so please bear with me. I'm currently working on a project using Sequelize with PostgresDB in Node and I need to search for a contact by email using findOrCreate function. The email entry is stored in JSON format (se ...

How can I use a button created with jQuery's .html() method to conceal a <div>?

I am facing an issue with implementing a simple banner that should appear in an empty element only when specific values are returned by an Ajax call. In the banner, I want to include a Bootstrap button that hides the entire div when clicked. Due to my la ...

Encountering a roadblock while trying to work with AngularJS Material radio buttons

In one of my projects, I have implemented a polling system where users can choose a question from a list and then proceed to the options page. On the options page, users can select their answer choices and submit their responses. The results are then displ ...

Efficiently merging data from various AngularJS resources

I've encountered a recurring scenario while developing Angular apps, especially when utilizing a Drupal API. I'm seeking advice on best practices for handling this specific issue. Currently, I am working on an app that interacts with a Drupal AP ...

List of dropdown options retrieved from SQLite database

I am attempting to retrieve data from an SQLite database table in order to populate a dropdown menu list. My thought process is outlined below. The main issue I am facing is how to integrate the JS function with the HTML section. HTML.html <label ...

Executing asynchronous functions within a loop using useEffect

My current scenario is as follows: export default function Component({ navigation }) { const [ item, setItem ] = useState([]); useEffect(() => { AsyncStorage.getItem('someItem') .then(data => JSON.parse(data)) ...

Having trouble selecting the first element with cursor on Jquery TokenInput?

I'm currently using a Bootstrap (v5.1.3) card that features an autocomplete field powered by jQuery's TokenInput. Everything seems to be functioning properly, except for the fact that I'm unable to access the first element of the field usin ...

Unable to inject dependencies into Karma testing framework

I am facing the challenge of injecting the $urlRouterProvider into my tests, but I persistently encounter the unknown provider issue. My setup involves ui.router and the testing of directives, requiring access to these providers to prevent test failures... ...

Is it possible to retain the volume level setting?

Whenever I am playing music and adjust the volume to 20%, the settings reset to 100% when the bot leaves the voice channel. It's frustrating having to manually set it back to 20% each time. Is there a way for my bot to remember the volume setting? con ...

Dynamic rows in an Angular 2 Material data table

I'm currently working on dynamically adding rows to an Angular 2 Data Table ( https://material.angular.io/components/table/overview) by utilizing a service called "ListService". This service provides me with the columns ("meta.attributes") to be displ ...

Is there a way for me to automatically update the contents of div x using Ajax whenever the contents of div y are changed with another Ajax call?

I've been struggling with this issue for quite some time now and haven't been able to find a solution. The situation is as follows: I have two divs, where div3 needs to update its content whenever div2 changes. Div2 is updated using ajax, so whe ...

Enable retrieval of calculated time duration in jQuery time picker

After implementing two separate timepickers for calculating a time duration, I am looking to access this computed duration for further calculations later on the page. How can I retrieve the duration that is already displayed to the user after using the sec ...

Error: 'm' is not defined when using the discord.js message collector

I am in the process of creating a Discord collector similar to this: let user = message.author; let guest = message.mentions.users.first() const collector = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id || m.auth ...

Adding content to an Array using forEach and updating innerHTML - A step-by-step guide

I'm curious about adding data content inside an array to innerHTML using the forEach method. For some reason, I can't get it to show up. Is it even possible? I'm dealing with dynamic data, so I need to loop through it and display it using i ...

Encountering a sudden problem while running gulp build due to a node_module - Surprising occurrence of Unexpected

Encountering an unexpected issue while running a gulp build process for a web app that I am struggling to resolve. The problem did not exist on the evening of 25/01/2019, but when attempting to execute the gulp build process this morning (30/01/2019), an ...

Glitch Uncovered in Excel Spreadsheet I Exported

I have a situation where I am working with an HTML table that includes both text and radio buttons. The issue arises when I attempt to export the table data along with the selected radio button values to Excel using the 'Export to Excel' button. ...

Determine the TR id when a button within a TD element is clicked using JavaScript/jQuery

Currently seeking a method to generate a unique identifier for use as a parameter in a JavaScript function. Specifically interested in extracting the id of the first td element if feasible. <tr id='it'><td id="#nameiron">Jason</td ...

PHP does not receive the uploaded image

I have encountered an issue while trying to create a form for editing a product. Whenever I upload an image, my PHP code is unable to locate the image and throws the following error: Notice: Undefined index: image in C:\xampp\htdocs\pages&bs ...

Load the Angular controller only after the service successfully fetches the Swagger API file

My current controller is dependent on a swagger-js enabled api. Unfortunately, the api remains unavailable until the swagger library acquires the swagger sepcification file. I am looking for a way to ensure that the controller only loads once the swagger A ...