Sortable tables with non existing value but different attributes

23 views
Skip to first unread message

Victor Martinez

unread,
Aug 1, 2017, 4:52:19 AM8/1/17
to Jenkins Developers

Hi there,

Any ideas how I can use the sortable type in a non value cell? I though I could use the "data-sort" attribute in the cell but it doesn't work.

As you can see below, there is a table based on two columns, first column contains the value "${job.name}" while the second column is just a colorful cell

<table class="sortable pane bigtable" id="lintTable">
    <thead>
      <tr>
          <th class="pane-header">Job Name</th>
          <th class="pane-header">Status</th>          
      </tr>
    </thead>
    <tbody id="lintBody">
        <j:forEach var="job" items="${it.jobSet.elements()}">
            <tr>
            <td>${job.name}</td>
            <td id="${job.defect. status}" style="background-color: ${job.defect.color?;"/>          
        </j:forEach>
   </tbody>
</table>

And its UI


I wish I could also order the Status column based on the colors but it seems the only sortable field is the value one: https://github.com/jenkinsci/jenkins/blob/master/war/src/main/webapp/scripts/sortable.js#L241

Any ideas whether the sortable class can be used with hidden values or different cell attributes?

Thanks

Antonio Muñiz

unread,
Aug 1, 2017, 6:04:21 AM8/1/17
to jenkin...@googlegroups.com
I don't see clean way to do it.
Best I can think of is to write your own JS event so it requests the values with a specific sort to the backend.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-dev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/5899e2b8-d025-46a2-9a67-5df566aebb75%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Antonio Muñiz
Software Engineer
CloudBees, Inc.

Stephen Connolly

unread,
Aug 1, 2017, 6:57:25 AM8/1/17
to jenkin...@googlegroups.com
Isn't it just a question of using the <td data="..."> attribute to have sorting on that attribute?

--

Victor Martinez

unread,
Aug 1, 2017, 9:49:35 AM8/1/17
to Jenkins Developers
indeed!! It works like a charm

Thanks

Antonio Muñiz

unread,
Aug 1, 2017, 7:24:31 PM8/1/17
to jenkin...@googlegroups.com
Oh, I thought you already tried that :)

El El mar, 1 ago 2017 a las 15:49, Victor Martinez <victormar...@gmail.com> escribió:
indeed!! It works like a charm

Thanks

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/bbc07e0a-c5f0-4a75-b609-db7bbf6efa56%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages