javascript - .Net 响应式 Gridview

标签 javascript asp.net twitter-bootstrap gridview

我正在使用 Bootstrap 处理一个 asp.net 站点。从 http://www.codeproject.com/Articles/547745/Add-Responsive-Behaviour-to-a-GridView-in-ASP-NET 安装了一个扩展在更新面板中处理 gridview 响应。

在笔记本电脑/个人电脑上测试时它很有效,但在通过手机实际查看带有 gridview 的页面时则无法工作。我测试的是安卓机。

它的作用:创建两个表实例,一个成为静态列,一个具有包含可滚动数据的溢出容器。

要查看使用此代码的 gridview 示例,请转到 http://dev6.web2market.com/ 。 单击标题中的“我的帐户”链接。 证书... 用户名:testing@testing.com 密码:SoTesting1! 将浏览器大小调整为 600 像素或更小,以便脚本启动。源代码将显示两个表 - 静态列,然后是溢出容器中的可滚动表。

我确实可以朝正确的方向插入。我在这里发布了完整的 javascript 文件:http://jsfiddle.net/jcw2m/9fquzoxj/ 。一个小样本(需要共享 fiddle 链接):

// Detect overflow by checking the table width against that of its parent tree
        function setupResponsiveTable(table) {
            tableWidth = table.width();
            if (table.parent().hasClass(_overflowContainer)) {
                tableWidth += $('.' + _staticContainer).width();
            }

            isResponsive = false;
            table.parents().each(function () {
                if (!$(this).hasClass(_overflowContainer)
					&& tableWidth > $(this).width()
					
				) {
                    isResponsive = true;
					

                    // break out of each
                    return (false);
                }
            });

最佳答案

对于任何需要这个的人。在 jquery.responsivetable.js 中,第 118 行左右,查找以下代码块:

                table.before(tableStatic);

            table.wrap(_divClass + _overflowContainer + '" style="float:left;' + _overflow + ':scroll;' + _overflow + '-y:hidden;"/>');
            tableStatic.wrap(_divClass + _staticContainer + '" style="float:left;"/>');

            if (options.scrollHintEnabled) {
                setupScrollHint(table, tos);
            }
            //This line added courtesy Marty. The class "table" is from bootstrap. When present on the table contained in the overflow div, it causes column headers to shift to the left instead of aligning with their respective column data. jc 12/17/14 
            ***table.removeClass("table");***           
        }

最后一行“table.removeClass("table");”这就是最终实现的技巧。

关于javascript - .Net 响应式 Gridview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27529040/

相关文章:

javascript - 如何在ngFor中实现固定div列?

html - Bootstrap 第一列隐藏,第二列全尺寸

javascript - 三个 JS : Load an OBJ, 转换为原点(场景中心)、轨道

javascript - 如何访问父 navController ionic 2

javascript - 从输出中删除第一个字母

asp.net - 自定义控件变为通用 "UserControl",而不是 Designer 类中的实际类型

c# - 如何循环遍历数据集并更改数据 C#

javascript - Angular 从扩展 Controller 调用父方法

asp.net - div background_image 中的 onclick 事件,其中图像在 pad_left 的某个位置?

php - Bootstrap : Dropdown as wide as the image