| Perfil de BradSharePoint BlogFotosBlogListas | Ayuda |
|
07 julio Hover (MouseOver) Highlight and Click to stay highlighted in a SharePoint list…While I was working in CustomWare I had the great pleasure of working with a guy called Sukri, a SharePoint developer. He's the kind of guy you'd mention something to, and it would tick over in the back of his mind, while he was doing his normal day-to-day work…. then a few days later, he'd come to you and say - "By the way, I know how we can address your client's requirements". Like he did for one of our clients… we were going through the client's needs, and we talked about how the client wanted to be able to present financial data in SharePoint, then allow the user to hover over and highlight a row of data… and allow the user to click the row and make it stay highlighted. He came up with a script that allowed you to do both – then one of the other guys, Ben, decided to enhance it so you could select and deselect multiple rows. Here's a screenshot of how it looked on the screen… Code: <script language="javascript" type="text/javascript">
var preRow;
var preClassName;
var orgBColor;
var hoverColor = "#ffcc99";
var selectedColor = "#d2d2ff";
var SPGridViewGuid = "{<<LIST GUID>>}-{<<LIST VIEW WEB PART GUID>>}";
_spBodyOnLoadFunctionNames.push("addSelectedRowEvent");
function addSelectedRowEvent() {
// Get all TABLE tag objects
var oTables = document.getElementsByTagName("TABLE");
for (var i=0;i < oTables.length; i++ )
{
// Filter where table id equal to SPGridView guid
if (oTables[i].id == SPGridViewGuid)
{
// Get all TR tag objects
var oRows = oTables[i].getElementsByTagName("TR");
for (var j=0;j < oRows.length; j++ )
{
if (j != 0)
{
// Add client event onMouseOver
oRows[j].onmouseover = function() {
this.style.backgroundColor = hoverColor;
}
// Add client event onMouseOut
oRows[j].onmouseout = function() {
this.style.backgroundColor = "";
}
// Add client event onClick
oRows[j].onclick = function() {
// If previous row is not null
if(typeof(preRow) != 'undefined')
{
// Assign previous stored background color and class name to TR objectHow it works: Configuration: Deployment: Storing the code as a separate file in a helper library gives you maximum flexibility, minimum change (no unghosting of pages) and version control of your code. Issues: Cheers! Brad Comentarios (1)Para agregar un comentario, inicia sesión con tu cuenta de Windows Live ID (si utilizas Hotmail, Messenger o Xbox LIVE, ya tienes una cuenta de Windows Live ID). Iniciar sesión ¿No tienes una cuenta de Windows Live ID? Regístrate
Vínculos de referenciaLa dirección URL del vínculo de referencia de esta entrada es: http://sharepointblog.spaces.live.com/blog/cns!74C8FB1191265567!526.trak Weblogs que hacen referencia a esta entrada
|
|
|