grid release custom row css class when click cancel (inline row edit)

0 Answers 76 Views
Grid
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
Aleksandr asked on 01 Mar 2023, 06:25 PM

to set the class

var hasInvalid = false;
                        // iterate the data items and apply row styles where necessary
                        var dataItems = e.sender.dataSource.view();
                        for (var j = 0; j < dataItems.length; j++) {
                            // Get the value of the discontinued cell from the current dataItem.
                            var isNotValid = dataItems[j].get("isNotValid");

                            // Find the table row that corresponds to the dataItem by using the uid property.
                            var row = e.sender.tbody.find("[data-uid='" + dataItems[j].uid + "']");
                            // Add the class if the row is discontinued.
                            if (isNotValid) {
                                row.addClass("warning");
                                hasInvalid = true;
                            } else {
                                row.removeClass("warning");
                            }
                        }

 

the workaround, but could be done the better way?


cancel: function (e) {
                        e.model.isNotValid = (e.model.ardentAgency.id === null
                            || !e.model.employeeFound 
                            || ((e.model.disposition === "" || e.model.disposition === null) && e.model.ardentDisposition.code === null)
                            || ((e.model.status === "" || e.model.status === null) && e.model.ardentStatus.code === null)
                            || ((e.model.businessState !== "" && e.model.businessState !== null) && e.model.ardentBusinessState.code === null)
                            || ((e.model.licenseType === "" || e.model.licenseType === null) && e.model.ardentLicenseType.code === null));                       
                        

                        if (e.model.isNotValid) {
                            var rowModel = e.sender.dataSource.get(e.model.recordId);
                            var modelUID = rowModel.get("uid");
                            var rowselector = "tr[data-uid='" + modelUID + "']";
                            setTimeout(function(){
                                console.log(rowselector);
                                $(rowselector).addClass("warning");
                            }, 500);                            
                        }
                    },

 

Nikolay
Telerik team
commented on 06 Mar 2023, 10:47 AM

Hi Aleksandr,

This approach is a valid one. You can obtain the row by using the uid attribute. The setTimeout function is required as the row re-renders once the Cancel button is clicked.

Regards,

Nikolay

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Aleksandr
Top achievements
Rank 1
Bronze
Bronze
Veteran
Share this question
or