简体   繁体   English

Jqgrid-表未显示响应行为

[英]Jqgrid - Table not displaying responsive behavior

Hi I Have the following code which displays the table using jqgrid. 嗨,我有以下代码,使用jqgrid显示该表。 But, i noticed that none of the jqGrid is being responsive. 但是,我注意到jqGrid都没有响应。

How can i make existing jqGrid responsive for tablet and smart phones 我该如何使现有的jqGrid能够响应平板电脑和智能手机

UPUDATE 更新

I have updated my code with the following 我已使用以下代码更新了我的代码

 $(window).on("resize", function () {
    var newWidth = $("#loanGrid").closest(".ui-jqgrid").parent().width();
   $("#loanGrid").jqGrid("setGridWidth", newWidth, true);
});

The respomnsiveness works but not completely. 记忆力是有效的,但并不完全有效。

Here is the code below and fiddle here HTML 这是下面的代码,在这里摆弄着 HTML

<div class="container-fluid">
   <div class="row">
      <div class="col-md-11">
         <h3 class="subheader"> Sample Info </h4>
         <div class="redmond">
            <table id="output"></table>
         </div>
     </div>
  </div>     
</div>

jqGrid JavaScript jqGrid JavaScript

$("#output").jqGrid({
    url: jsonData,
    mtype: "GET",
    datatype: "json",
    /*  postData: {
          json: JSON.stringify(data)
      },
      */
    colModel: [
      /**    { name: 'ClientID', label:'ClientID',width: 80, key: true },****/
      {
        name: 'Symbol',
        label: 'Symbol',
        align: 'left',
        width: 65
      }, {
        name: 'Description',
        label: 'Description',
        align: 'left',
        width: 165
      }, {
        name: 'ShareQuantity',
        label: 'ShareQuantity',
        align: 'right',
        width: "85",
        formatter: 'currency',
        formatoptions: {
          prefix: " ",
          suffix: " "
        }
      }, {
        name: 'SharePrice',
        label: 'Share Price',
        align: 'right',
        width: 100,
        template: "number",
        formatoptions: {
          prefix: " $",
          decimalPlaces: 4
        }
      },
      /*{ label: 'Value1', 
                  name: 'Value1', 
                  width: 80, 
                  sorttype: 'number', 
                  formatter: 'number',
                  align: 'right'
              }, */
      {
        name: 'TotalValue',
        label: 'Total Value',
        width: 160,
        sorttype: 'number',
        align: "right",
        formatter: 'currency',
        formatoptions: {
          prefix: " $",
          suffix: " "
        }
      }, {
        name: 'LTVRatio',
        label: 'LTV Ratio',
        width: 70,
        sorttype: 'number',
        align: "right",
        formatter: 'percentage',
        formatoptions: {
          prefix: " ",
          suffix: " "
        }
      }, {
        name: 'LTVCategory',
        label: 'LTV Category',
        width: 120,
        width: 165
      },

      {
        name: 'MaxLoanAmt',
        label: 'MaxLoanAmount',
        width: 165,
        sorttype: 'number',
        align: "right",
        formatter: 'currency',
        formatoptions: {
          prefix: " $",
          suffix: " "
        }
      }

    ],
    additionalProperties: ["Num1"],
    /*beforeProcessing: function (data) {
        var item, i, n = data.length;
        for (i = 0; i < n; i++) {
            item = data[i];
            item.Quantity = parseFloat($.trim(item.Quantity).replace(",", ""));
            item.LTVRatio = parseFloat($.trim(item.LTVRatio *10000).replace(",", ""));
            item.Value = parseFloat($.trim(item.Value).replace(",", ""));
            item.Num1 = parseInt($.trim(item.Num1).replace(",", ""), 10);
            item.Num2 = parseInt($.trim(item.Num2).replace(",", ""), 10);
        }
    }, */
    iconSet: "fontAwesome",
    loadonce: true,
    rownumbers: true,
    cmTemplate: {
      autoResizable: true,
      editable: true
    },
    autoResizing: {
      compact: true
    },
    forceClientSorting: true,
    sortname: "Symbol",
    footerrow: true,
    caption: "<b>Collateral Value</b> <span class='pull-right' style='margin-right:20px;'>Valuation as of: " + mmddyyyy + "</span>",


    loadComplete: function() {
      var $self = $(this),
        sum = $self.jqGrid("getCol", "Price", false, "sum"),
        sum1 = $self.jqGrid("getCol", "MaxLoanAmt", false, "sum");
      //ltvratio =  $self.jqGrid("getCol","LTVRatio:addas", "Aved Loan Amount");
      $self.jqGrid("footerData", "set", {
        LTVCategory: "Max Approved Loan Amount:",
        Price: sum,
        MaxLoanAmt: sum1
      });
    }
  });

  //jQuery("#loanGrid").jqGrid('filterToolbar', { stringResult: true,  searchOnEnter: false, defaultSearch: "cn" });
});

You can use Bootstrap classes .visible-* or hidden-* to hide/show some elements on the page depend on the window resolution (see the documentation ). 您可以使用Bootstrap类.visible-*hidden-*来隐藏/显示页面上的某些元素,具体取决于窗口的分辨率(请参阅文档 )。 The properties classes , labelClasses or colModel can be used in free jqGrid (starting with version 4.8, see here and here ) to assign the classes to the column. 属性classeslabelClassescolModel可以在免费的jqGrid中使用 (从4.8版开始,请参见此处此处 )以将这些类分配给该列。 For example the demo https://jsfiddle.net/OlegKi/w7pxts0z/7/ uses 例如演示https://jsfiddle.net/OlegKi/w7pxts0z/7/使用

classes: "hidden-xs hidden-sm", labelClasses: "hidden-xs hidden-sm"

in LTVCategory column and the properties LTVCategory列和属性中

classes: "hidden-xs", labelClasses: "hidden-xs"

in ShareQuantity and SharePrice columns. ShareQuantitySharePrice列中。 As the result the column LTVCategory will be hidden on "extra small devices" (width<768px) and "small devices" (width<992px, but width>=768px). 结果,列LTVCategory将被隐藏在“额外的小型设备”(宽度<768px)和“小型设备”(宽度<992px,但宽度> = 768px)上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM