This is a migrated thread and some comments may be shown as answers.

How to get the class (className) of cell being edited

3 Answers 153 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 03 Dec 2018, 06:19 PM

i have a grid where the current input cell that is being edited may have had a class added to it in a prior edit to indicate that it  had been changed

 

or the current input cell being edited may be in process of being edited and has the k-dirty flag

 

Can I interrogate that cell in javascript or jquery  to determine the class or classes that are attached to that input cell?

 

I am not able to find any examples 

 

thanks

Jim

 

 

 

 

3 Answers, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 05 Dec 2018, 11:22 AM
Hi Jim,

Based on the described scenario I guess that you would like when there are pending changes in the Grid. Please correct me if I am mistaken.

If this is the requirement you can use the DataSource hasChanges method. It will check if there are any unsaved changes in the grid and return true or false. Then, if you would like to get the modified records you can use an approach similar to the one described in the thread below:


Give the suggestion a try and let me know how it works for you.


Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
James
Top achievements
Rank 1
answered on 05 Dec 2018, 03:20 PM

Hi Viktor

No - I am not looking to see if the grid has changes - I can get that

 During grid processing, different classes may have been added to a cell depending on the process

 Subsequently if that cell is being edited again, I would like to find which class or classes have been attached to that cell

in the Edit or Save events, I can get the reference to that specific cell - but not sure how to see what classes are attached to the cell

 

thanks

Jim

0
Viktor Tachev
Telerik team
answered on 06 Dec 2018, 01:14 PM
Hello Jim,

When the edit event is raised the cell would already be in edit mode. At this point the cell will have a k-edit-cell class applies to it and the previous CSS classes will be removed. 

If you would like to access the CSS classes applied to a cell before it enters edit mode you can use jQuery and handle the mousedown event for the td elements in the Grid. In the event handler you will have access to the clicked cell and the classes applied to that element.


$(".k-grid").on("mousedown", "tbody td", function(e) {
    console.log(e.target.classList);
});


The dojo below outlines the approach:



Regards,
Viktor Tachev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Viktor Tachev
Telerik team
James
Top achievements
Rank 1
Share this question
or