0

我想在表格视图中的某个字母之后添加 eclipseies,我正在运行时创建表格。你能建议我吗。在一列中我想要不超过 10 个字符,所以我需要 eclipseies,我分享我的代码。

不工作............

在身体上加载此功能..

 function GetDepartureStationDashboard()
        {      

            document.getElementById('loadingImg').style.visibility = "visible"; 
             var pl = new SOAPClientParameters();
             var params = getParams();
             var parameter1 = unescape(params["getStationCode"]);
             stationCode=parameter1;
             var parameter2 = unescape(params["getStationDesc"]).replace(/[+]/g," ");
             document.getElementById("headingcontent").innerHTML = parameter2;
             pl.add("parameter1", parameter1);
             SOAPClient.invoke(WSDLURL, "GetDepartureStationDashboard", pl, true, GetDepartureStationDashboard_callBack);
        }




function GetDepartureStationDashboard_callBack(r)
{
    document.getElementById('loadingImg').style.visibility = "hidden";
    var tbl = document.getElementById('mainBodyDivContent');
    //tbl.innerHTML = "";
    for (var i = 0; i <r.length-1; i++) {
        var tr = document.createElement('tr');
        tr.setAttribute('id', i);
        (function(id) {
            tr.onclick = function() {
                if(myScroll.isScrolling) {return;}
//window.clearTimeout(myTimedCall);
//window.clearInterval(myTimedCall);
         window.location.href="route.html?RID="+r[id].RID+"&StationCode="+stationCode;
            };
        }(i));

        var td1 = document.createElement('td');
        td1.setAttribute('width', '10%');
        td1.setAttribute("align","center");
        td1.innerHTML = r[i].platformNo;;

        var td2 = document.createElement('td');
        td2.setAttribute('width', '10%');
        td2.setAttribute("align","center");
        td2.innerHTML = r[i].schDepart;


        var td3 = document.createElement('td');
        td3.setAttribute('width', '5%');
        td3.setAttribute("align","center");
        td3.innerHTML ="-";

        var td4 = document.createElement('td');
        td4.setAttribute('width', '10%');
        td4.setAttribute("align","center");
        td4.innerHTML =r[i].destSchArrival;
        **************No dot come if word is bigger******
        var td5 = document.createElement('td');
        td5.setAttribute('width', '10%');
        td5.setAttribute("align","center");
        td5.setAttribute('style', 'text-overflow: ellipsis;');
        td5.setAttribute('style', 'overflow: hidden;');
        td5.setAttribute('style', 'white-space: nowrap;');
        td5.innerHTML = r[i].stationName;


        var td6 = document.createElement('td');
        td6.setAttribute('width', '15%');
        td6.setAttribute("align","center");
        td6.setAttribute('style', 'text-overflow: ellipsis;');
        td6.innerHTML =" (" + r[i].crsCode + ")" ;;

        var td7 = document.createElement('td');
        td7.setAttribute('width', '20%');
        td7.setAttribute("align","center");

        var td8 = document.createElement('td');
        td8.setAttribute('width', '20%');
        td8.setAttribute("align","center");
        td8.setAttribute('style', 'text-overflow: ellipsis;');
            if(r[i].schDepart == r[i].expDepart)
    {
        td7.innerHTML = "<img src=\"images/correct-icon.png\" width=\"20\" height=\"20\" />";
        td8.innerHTML="";
    }
    else 
    {
        td7.innerHTML = "<img src=\"images/error.png\" width=\"20\" height=\"20\" />";
        td8.innerHTML=r[i].expDepart;
    }

        tr.appendChild(td1);
        tr.appendChild(td2);
        tr.appendChild(td3);
        tr.appendChild(td4);
        tr.appendChild(td5);
        tr.appendChild(td6);
        tr.appendChild(td7);
        tr.appendChild(td8);


        tbl.appendChild(tr);
    }
4

1 回答 1

0

你需要使用text-overflow:ellipsis你想要做的事情。看看这里http://www.quirksmode.org/css/textoverflow.html或者只是搜索“溢出省略号”以获得更多示例

于 2012-09-04T14:11:24.603 回答