zoukankan      html  css  js  c++  java
  • Extjs4.2.0 Grid 的单元格提示

    官方docs有个例子,给出的是行提示

    var view = grid.getView();
    var tip = Ext.create('Ext.tip.ToolTip', {
        // The overall target element.
        target: view.el,
        // Each grid row causes its own separate show and hide.
        delegate: view.itemSelector,//选择器这里选择'tr.x-grid-row';被选择器选中的元素都会添加tip
        // Moving within the row should not hide the tip.
        trackMouse: true,
        // Render immediately so that tip.body can be referenced prior to the first show.
        renderTo: Ext.getBody(),
        listeners: {
            // Change content dynamically depending on which element triggered the show.
            beforeshow: function updateTipBody(tip) {
           //view.getRecord(tip.triggerElement)//参数是Ext.Element/HTMLElement;当前使用的是 HTMLElement tr元素 tip.update(
    'Over company "' + view.getRecord(tip.triggerElement).get('company') + '"'); } } });

    /*
    可见如果要改成单元格提示
    1.更改选择器参数为 单元格,可以通过fierbug 查看你所需要的元素特征来设置
    2.getRecord 需要一个 HTMLElement(表格行tr)参数;当我们的选择器选中了(td),可以通过 (td).parentElement 获取HTMLElement(表格行tr),完成参数设定
    */

     修改后的源代码如下

    var view = grid.getView();
    var tip = Ext.create('Ext.tip.ToolTip', {
        // The overall target element.
        title : 'Detail',
        minWidth : 800,
        maxWidth : 800,
        minHeight : 200,
        maxHeight : 200,
        showDelay : 1000,
        autoHide : false,
        target : view.el,
        // Each grid row causes its own separate show and hide.
        delegate : '.x-grid-cell-special',
        // Moving within the row should not hide the tip.
        trackMouse : true,
        // Render immediately so that tip.body can be referenced prior to
        // the first show.
        renderTo : Ext.getBody(),
        listeners : {
            // Change content dynamically depending on which element
            // triggered the show.
            beforeshow : function updateTipBody(tip) {
                if (Ext.EventObject.getCharCode() !== Ext.EventObject.ALT)//按住alt键才提示
                    return false;
                var vid = view.getRecord(tip.triggerElement.parentElement).get('Fid');
                // var vid = view.getRecord(tip.triggerElement).get('Fid');
                tip
                        .update('<iframe frameborder="0" width="780" height="180" src=S/xs_markets/xs_markets_list_data.asp?Act=getDetail&Fid='
                                + vid + '&pp=0></iframe>');
            }
        }
    });
  • 相关阅读:
    我藏在你的心里,你却不愿意寻找# BUG躲猫猫
    阴间需求之跨端登录
    神奇的props
    map与filter:你先我先?
    阴间BUG之动态路由刷新几率回首页
    阴间BUG之动态路由添加失败
    我在eltable就变了个模样,请你不要再想我,想起我
    SCP打包部署方法
    indexOf 与 includes
    YACC和BISON学习心得
  • 原文地址:https://www.cnblogs.com/xsSystem/p/3101346.html
Copyright © 2011-2022 走看看