Is there a way to do sublist line highlighting on ...
# suitescript
k
Is there a way to do sublist line highlighting on a suitelet?
m
I've heard of people using DOM manipulation in a client script to achieve this. Personally I just used Text fields and style with html
Copy code
const onRequest = (scriptContext) => {
    const list = serverWidget.createList({ title: "Test List" });

    list.addColumn({
      id: "custpage_test_field",
      type: serverWidget.FieldType.TEXT,
      label: "Test Field",
    });

    list.addRows({
      rows: [
        { custpage_test_field: "Line 1" },
        { custpage_test_field: "<mark>Line 2</mark>" },
        { custpage_test_field: "Line 3" },
      ],
    });

    scriptContext.response.writePage({ pageObject: list });
  };
message has been deleted
t
I am trying that in sublist field and that isn't happening, @michoel.
@Kris Wood Did you figure out for sublist ?
c
Depending on how the html table is structured, you can iterate through the cells in a row and change the color with .style.setProperty("background-color", "#00CC00", "important") applied to the cell element
The "important" property might not be neccesary, but it was for me when attempting this on a list isntead of a sublist
playing around in the chrome dev console, seems to work.
Copy code
let table = document.getElementById('item_splits')
for (let i = 0; i < table.rows[2].cells.length; i++) {
    table.rows[2].cells[i].style.setProperty("background-color", "#00CC00", "important")
}
message has been deleted
t
Hello @Corey Schwoebel, while this is working in console. I am not getting the row array elements in client script. getting
Cannot read property 'cells' of undefined
Here is a screenshot from console.
c
Are you willing to post the client script?
t
yes, that is absolutely same code
c
Are you using an entry point?
t
Untitled
No
c
Hmm, im at a loss there. I know there
**I wonder if the sublist is still being populated after the DOM has finished loading.
t
Visually it doesn't seems so, is there any way to confirm ?
c
You could use setTimeout to wait a second or two before executing the code, that would rule it out. I got nothin' after that
t
Yes it works, have to check it for long sublists though, Thanks a lot
c
Glad i could help!
🙏 1