jQWidgets筆記,jqwidgets

來源:互聯網
上載者:User

jQWidgets筆記,jqwidgets

http://www.jqwidgets.com/jquery-widgets-demo/

常用:

//設定列間距可調
$('#jqxGrid').jqxGrid({ columnsresize: false});

//擷取是否可調值
var columnsresize = $('#jqxGrid').jqxGrid('columnsresize');

//資料繫結完成後事件
$("#jqxGrid").on("bindingcomplete", function (event) {// your code here.});

var rows = $('#jqxGrid').jqxGrid('getrows');//擷取整個資料行數

列驗證
columns:[
{text:'日期',dataField:'DT',width:'50%',validation:function(){
if(value==''){

return{message:'日期必須填寫',result:false};
}
return true;
}
}
]


jqxGrid Demo:

http://www.jqwidgets.com/jquery-widgets-demo/demos/jqxgrid/index.htm#demos/jqxgrid/defaultfunctionality.htm

<!DOCTYPE html><html lang="en"><head>    <title id='Description'>This demo illustrates the basic functionality of the Grid plugin. The jQWidgets Grid plugin offers rich support for interacting with data, including paging, grouping and sorting.     </title>    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />    <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script>     <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>    <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script>     <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script>     <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script>     <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script>     <script type="text/javascript" src="../../scripts/demos.js"></script>    <script type="text/javascript">        $(document).ready(function () {            var url = "../sampledata/products.xml";//資料url            // prepare the data            var source =            {                datatype: "xml",                datafields: [                    { name: 'ProductName', type: 'string' },                    { name: 'QuantityPerUnit', type: 'int' },                    { name: 'UnitPrice', type: 'float' },                    { name: 'UnitsInStock', type: 'float' },                    { name: 'Discontinued', type: 'bool' }                ],//資料欄位定義                root: "Products",//節點根(可選)                record: "Product",                id: 'ProductID',                url: url            };//格式化var cellsrenderer = function (row, columnfield, value, defaulthtml, columnproperties, rowdata) {                if (value < 20) {                    return '<span style="margin: 4px; float: ' + columnproperties.cellsalign + '; color: #ff0000;">' + value + '</span>';                }                else {                    return '<span style="margin: 4px; float: ' + columnproperties.cellsalign + '; color: #008000;">' + value + '</span>';                }            }//資料適配            var dataAdapter = new $.jqx.dataAdapter(source, {                downloadComplete: function (data, status, xhr) { },                loadComplete: function (data) { },                loadError: function (xhr, status, error) { }            });            // initialize jqxGrid            $("#jqxgrid").jqxGrid(            {                width: 850,                source: dataAdapter,//資料來源                pageable: true,//是否分頁                autoheight: true,//是否自動高度                sortable: true,//是否排序                altrows: true,//是否行間顏色區分                enabletooltips: true,//是否工具提示                editable: true,//是否可編緝      columnsresize: true,//列間距是否可調整selectionmode: 'multiplecellsadvanced',//選擇模式 columns: [ {text: 'Product Name', columngroup: 'ProductDetails', datafield: 'ProductName', width: 250 }, { text: 'Quantity per Unit', columngroup: 'ProductDetails', datafield: 'QuantityPerUnit', cellsalign: 'right', align: 'right', width: 200 }, { text: 'Unit Price', columngroup: 'ProductDetails', datafield: 'UnitPrice', align: 'right', cellsalign: 'right', cellsformat: 'c2', width: 200 }, { text: 'Units In Stock', datafield: 'UnitsInStock', cellsalign: 'right', cellsrenderer: cellsrenderer, width: 100 }, { text: 'Discontinued', columntype: 'checkbox', datafield: 'Discontinued'} ], columngroups: [ { text: 'Product Details', align: 'center', name: 'ProductDetails' } ]//列資料繫結 });//資料繫結完成後事件$("#jqxGrid").on("bindingcomplete", function (event) {// your code here.});}); </script></head><body class='default'><span style="white-space:pre"></span><div id='jqxWidget' style="font-size: 13px; font-family: Verdana; float: left;"><span style="white-space:pre"></span><div id="jqxgrid"> </div><span style="white-space:pre"></span></div></body></html>


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.