Dynamic text Length

Dynamic text Length

Massimo74Massimo74 Posts: 83Questions: 0Answers: 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: 9,791Questions: 0Answers: 1,620

    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: 83Questions: 0Answers: 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: 9,791Questions: 0Answers: 1,620
    edited March 30

    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: 83Questions: 0Answers: 0
    edited March 28

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

  • kthorngrenkthorngren Posts: 10,585Questions: 25Answers: 2,409
    edited March 28

    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

Sign In or Register to comment.