Dynamic text Length

Dynamic text Length

Massimo74Massimo74 Posts: 85Questions: 1Answers: 0

Here
I have the following text length problem I would like that :

when the screen is in 'mobile-p' mode the text (row [0].substr (0,10))
when in 'mobile-l' mode the text assumes (row [0].substr (0,20))
when in 'tablet-l' mode the text assumes (row [0].substr (0,30))
when in 'desktop' mode the text assumes (row [0].substr (0,50))

Replies

  • colincolin Posts: 15,118Questions: 1Answers: 2,583

    We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

  • Massimo74Massimo74 Posts: 85Questions: 1Answers: 0

    Hi Colin the Test case is here http://live.datatables.net/vagelotu/2/edit .
    I had also put it in the previous post "Here".
    Thanks

    i also noticed another problem Column ORDER not working

  • colincolin Posts: 15,118Questions: 1Answers: 2,583
    edited March 2020

    Responsive isn't working in your example as you haven't included the sources - see here. There isn't a way to reduce the text though - and if you did, it would cause a redraw which due to the reduced widths might make columns appear again!

    Colin

  • Massimo74Massimo74 Posts: 85Questions: 1Answers: 0
    edited March 2020

    Thanks Colin.
    whi order columns on column NAME not work ???

  • kthorngrenkthorngren Posts: 20,148Questions: 26Answers: 4,736
    edited March 2020

    You have this:

                             else if ( type === 'display' || type === 'filter' ) {
                                 if(row!=='' && row[0] !=null)
                                 {
                                    return '<span title="'+row[0]+'">'+row[0].substr(0,30)+'....</span>';
                                 }
                                 else
                                 {
                                    return "";
                                 }
                                 return row;
                             }
                             else{
                               return "";
                             }
                           }
    

    The last return in the else clause should be return data;. Basically you are returning the same value ("") for all rows for the sort operation. You should have something like this:

                             else if ( type === 'display' || type === 'filter' ) {
                                 if(row!=='' && row[0] !=null)
                                 {
                                    return '<span title="'+row[0]+'">'+row[0].substr(0,30)+'....</span>';
                                 }
                                 else
                                 {
                                    return "";
                                 }
                                 return row;
                             }
                             else{
                               return data;
                             }
                           }
    

    Kevin

This discussion has been closed.