This is a migrated thread and some comments may be shown as answers.

showing only specified number of characters in grid cell

2 Answers 755 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mic
Top achievements
Rank 1
Mic asked on 13 Nov 2012, 03:54 PM
Hallo,

Is there any way to make my grid cell to show only ie 50 characters from what i put in that cell?
And is it possible to bind this cell to a click event on which the cell would become great enough to show all sentence?

Thanks in advance

2 Answers, 1 is accepted

Sort by
0
Maxim
Top achievements
Rank 1
answered on 19 Nov 2012, 05:23 PM
I was trying to do something like you describe. However I did not do it based on character count. I used CSS to style my cell to support overflow as below.
#grid div.k-grid-content tr[data-uid] {
    -ms-text-overflow: ellipsis;
    -o-text-overflow: ellipsis;
    text-overflow: ellipsis;
}
#grid div.k-grid-content tr[data-uid] td {
    white-space: nowrap;
}
Then I added a class to my cell in grid config to be able to support tool tip popup:
$("#grid").kendoGrid({
    columns: [
        {
            field: "Description",
            title: "Description",
            width: 90,
            attributes: { "class": "popup" }
        }
    ]
});
And later I setup all my cells to display tool tip using jQuery UI:
$("#grid").tooltip({
    items: "td.popup",
    content: function () {
        var element = $(this);
        if (element.is("td.popup")) {
            return element.html();
        }
    }
});

0
Kurtis
Top achievements
Rank 1
answered on 18 Feb 2016, 03:24 PM

 div#Grid.k-widget.k-grid table tbody tr[data-uid] td {
    white-space: nowrap;
    max-width: 200px;
}

 

Max Width Element cut down the cell and gave it the ellipsis for me.  You can follow the same steps above to add a clickable function. 

Tags
Grid
Asked by
Mic
Top achievements
Rank 1
Answers by
Maxim
Top achievements
Rank 1
Kurtis
Top achievements
Rank 1
Share this question
or