You are viewing limited content. For full access, please sign in.

Question

Question

Forms Table row sorting descending order

asked on September 7, 2022 Show version history

Hi Community!!

Does someone here know how to sort Forms table row numbers into descending order?

see the attached sample Code & form below.

$(document).ready( function () {
  $('#q99.cf-table-tbody-tr').DataTable({
    "searching": true,
    "paging": true,
    "order": [[ 0, "desc"]],
   // "ordering" : true,
   //"columnDefa" :[{
    //  "targets" : [0,1,2],
     // "orderable" : false
    //  }]
  });

});

 

 

Thanks in advance :)

 

0 0

Replies

replied on September 7, 2022

This will not exactly answer your question but it does show how to move rows in a table up one or down one and may give you an idea on what would work for you.  https://answers.laserfiche.com/questions/113991/Table-Rows-Position

0 0
replied on September 7, 2022

Genny Maguire Thank you, I will try this.

0 0
replied on September 8, 2022

Hi Genny Maguire I try and check what you suggested but it is far from what our client need :( do you have any suggestions more closer? Thank you in advance.

0 0
replied on September 9, 2022

Sorry but I don't. 

0 0
replied on September 12, 2022 Show version history

I have a solution to this now. It takes a couple formulas, a couple hidden fields, some CSS and some JavaScript. I'm guessing there is another way but this is what I have right now. 

First I created a number field in the table that I would use the Field Rules to hide. I named this field 'Hidden_Row' and I set it's default value to 1. I named my table 'The_Table', so you will need to change where it's used in the following formulas to the name of your table.

Then I created a number field outside of the table that will also be hidden using Field Rules and gave it the following formula. I named this field 'Table_Row_Count'

=SUM(The_Table.Hidden_Row)+1

I could not get it to work with the actual row label so I used CSS and JavaScript to make a fake label out of the first column in the table.  I gave this column the class name of 'fakeLabel'. I gave it the following formula.

=Table_Row_Count-ROW()

The CSS

.fakeLabel input {background-color: #ffffff !important;border: 0px solid; font-weight: bold;text-align:right;}

The JavaSript

$(document).ready (function () {
 
  /* setting the fakeLabel as readonly here so that it keeps the value set by the formula */
  $('.fakeLabel input').attr('readonly', true); 
  
  /* add read only to new rows in a table */	
  $('.cf-table-add-row').on('click',function(){
    $('.fakeLabel input').attr('readonly', true);
  }); 

}); /* END: $(document).ready  */

 

 

 

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.