2014-01-08 44 views
1

我拼命尝试在某些jqgrid单元格上实现jQuery工具提示。我格式化的单元格有自己的标题是这样的:在jqgrid自定义格式化单元格上应用jquery工具提示

<td role="gridcell" style="" title="Toto, Tata" aria-describedby="MyTaskUserView_TaxpayerName"> 
    <span class="fullCellSpan customTooltip" title="123456" originalvalue="Toto Tata">Toto Tata</span> 
</td> 

我想呼吁包含标题我跨度提示:

$("td span.customTooltip").tooltip(); 

而且我不明白为什么它不工作。

如果我这样称呼它

$(document).tooltip(); 

它会工作,但随后将应用具有这不是我想要的标题元素的每个元素上的提示。

这就像它不承认我给我的HTML路径,我不明白。

在此先感谢您的帮助

回答

0

我发现的bug,当我打电话的工具提示电网尚未完成加载。 由于我使用了JqGrid ASP.NET MVC许可证,因此我使用模型的ClientSideEvents.GridInitialized属性知道网格何时加载,然后触发工具提示。

MyGrid.ClientSideEvents.GridInitialized = "initGrid"; 

function initGrid() { 
$("td span.fullCellSpan").tooltip({ 
    hide: { 
     effect: "fade", 
     duration: 500 
    }, 
    position: { 
     my: "left center", 
     at: "right top", 
     collison: "flip" 
    }, 
    show: { 
     effect: "fade", 
     duration: 800 
    } 
}); 
} 

希望这可以帮助其他用户。

0

较新的方法是使用cellattr功能,在asp.net库是:

<Formatter> 
    <trirand:CustomFormatter SetAttributesFunction="clientSideFunctionName" /> 
</Formatter> 

更多细节可以在这里找到:https://stackoverflow.com/a/5281391/356218https://stackoverflow.com/a/12215880/356218

和JS看起来会是like like:

function clientSideFunctionName(rowId, tv, rawObject, cm, rdata) { 
    //conditional formatting 
    if (Number(rawObject[colMap.missingBooks]) > 0) { 
     return ' style="background-color:#FFCCCC" title="tooltips are cool!"'; 
    } else { 
     return ''; 
    } 
} 
相关问题