Custom renderer and row deletion issue

  • 1
  • Question
  • Updated 3 years ago
  • Answered
I have a custom field renderer which highlights background color of a table row if certain condition is true. However, if a user clicks the delete button on that row because of the custom renderer that row does not get highlighted in 'Pink'.

To fix this, I am calling another snippet using model action. Idea is - if a model has rows flagged for deletion the snippet should get called, temporarily disable the custom highlighting.
 

var field = arguments[0];  
$ = skuid.$;
value = arguments[1];

 if(field.element.hasClass("finished-sentence")) {
      field.element.removeClass("finished-sentence");
} else if (field.element.hasClass("unfinished-sentence")){            field.element.removeClass("unfinished-sentence");
}

However, I am getting errors in console on addClass and RemoveClass. Help please!!
Photo of Rupali G

Rupali G

  • 378 Points 250 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Rupali,

console.log(arguments); at the beginning of your snippet. The arguments for a model action are not the same as the arguments for a field renderer. Check your arguments, and go from there.

That said, there might be a better method, depending on what you're going for:

Instead of the model action, I'd replace the canned "Flag rows for Deletion" row action with a row action that runs multiple actions: (1) flag the row for deletion, and (2) run a snippet to change the highlighting just for that row.

That way you don't have to eliminate the highlighting from the entire table.
Photo of Rupali G

Rupali G

  • 378 Points 250 badge 2x thumb
Thanks a lot, Matt. I appreciate it. Your approach sounds better. Would give it a try. :-)