檢視 Jqgrid 的原始碼
←
Jqgrid
跳至導覽
跳至搜尋
由於以下原因,您無權編輯此頁面:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
{{DISPLAYTITLE:jqGrid}} '''jqGrid''',一套基於[[jQuery]]基礎的Gird *[http://www.trirand.com/blog/?page_id=6 jqGrid] *[http://www.trirand.com/jqgridwiki/doku.php?id=wiki:jqgriddocs jqGrid Documentation] *[http://www.trirand.com/blog/jqgrid/jqgrid.html jqGrid Demo] ==技術文件== *[http://www.cc.ntu.edu.tw/chinese/epaper/0021/20120620_2109.html JqGrid—功能強大的jQuery Grid Control] *[http://huan-lin.blogspot.tw/2012/12/aspnet-mvc-4-with-jqgrid-step-by-step.html Huan-Lin 學習筆記: ASP.NET MVC 4 與 jqGrid 入門實作] *[http://haacked.com/archive/2009/04/14/using-jquery-grid-with-asp.net-mvc.aspx Using jQuery Grid With ASP.NET MVC] *[http://www.misterngan.com/category/jqgrid/ jqGrid實用技巧 - Mister Ngan] *[http://www.trirand.com/blog/jqgrid/downloads/jqgriddocs.pdf jqgriddocs.pdf](官方文件) ==FAQ== ===Server端傳入參數=== ;讀取資料(一般) *在jqGrid的初始定義中, 由 url 參數指定Server端網址 *傳入參數 _search (不搜尋=false) *傳入參數 sidx 排序用的資料欄位名稱 *傳入參數 sord 排序方向 ("desc","asc") *傳入參數 page 第幾頁 *傳入參數 rows 每頁資料筆數 ;讀取資料(單一搜尋條件模式) *傳入參數 _search (搜尋=true) *傳入參數 sidx 排序用的資料欄位名稱 *傳入參數 sord 排序方向 ("desc","asc") *傳入參數 page 第幾頁 *傳入參數 rows 每頁資料筆數 *傳入參數 searchField 搜尋的攔位名稱 *傳入參數 searchString 搜尋內容 *傳入參數 searchOper 搜尋條件 {| width="100%" class="wikitable" |- !條件!!反向條件 |- |等於="eq"||不等於="ne" |- |小於="lt"||小於等於="le" |- |大於="gt"||大於等於="ge" |- |開始於="bw"||不開始於="bn" |- |在其中="in"||不在其中="ni" |- |結束於="ew"||不結束於="en" |- |包含="ce"||不包含="nc" |- |} ;讀取資料(多重搜尋條件模式) *傳入參數 _search (搜尋=true) *傳入參數 sidx 排序用的資料欄位名稱 *傳入參數 sord 排序方向 ("desc","asc") *傳入參數 page 第幾頁 *傳入參數 rows 每頁資料筆數 *傳入參數 filters 篩選條件(json格式), 例如: {"groupOp":"AND"%2C"rules":[{"field":"CategoryNo"%2C"op":"eq"%2C"data":"1"}]} *傳入參數 searchField (不使用, 為空字串) *傳入參數 searchString (不使用, 為空字串) *傳入參數 searchOper (不使用, 為空字串) ;新增/修改/刪除 *在jqGrid的初始定義中, 由 editurl 參數指定Server端網址, 預設採POST模式 *傳入參數 oper (新增="add", 修改="edit", 刪除="del") *傳入參數 id (修改或刪除時, 表單模式新增時="_empty", inline模式新增時="jqg1") *傳入參數 (新增或修改時,資料欄位) ===欄位定義=== * 宣告為ID用的欄位 key: true * 欄位寬度 width: 55 * 對齊 align: "right" * 可編輯 editable: true * 可隱藏 hidden: true * 可搜尋 search: true * 可排序 sortable: true * 編輯時必填 editrules: { required: true } * 參照:[http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules wiki:common_rules - jqGrid Wiki] {| width="100%" class="wikitable" |- !模式 !一般顯示(預設值為'text') !編輯時(預設值為'text') !搜尋時(預設值為'text') |- |text | | | |- |textarea | |edittype: "textarea", editoptions: { rows: "4", cols: "45" } | |- |select |formatter: "select", formatoptions: { value: "C:支票;N:本票;E:匯票", defaultValue: "C", disabled: true } |edittype: "select", editoptions: { value: "C:支票;N:本票;E:匯票" } |stype: "select", searchoptions: { value: "C:支票;N:本票;E:匯票" } |- |checkbox |formatter: "checkbox", formatoptions: { value: "True:False" }, defaultValue: "False", disabled: false } |edittype: "checkbox", editoptions: { value: "True:False" } |stype: "checkbox", searchoptions: { value: "True:False" } |- |currency |formatter: "currency", formatoptions: { decimalPlaces: 0, defaultValue: "", prefix: '', suffix: '', thousandsSeparator: ',' } | | |- |} ===在資料列使用預設的(編輯、刪除、儲存、取消)的按鈕=== *參照: **[http://stackoverflow.com/questions/5196387/jqgrid-editactioniconscolumn-events jqgrid EditActionIconsColumn Events] *在 colModel 裡用 { name: 'act', index: 'act', width: 60, sortable: false, formatter:'actions'} *同時使用 inline編輯模式,需先 var 定義 2個變數備用 <pre> var lastsel; var lastrow = null; 例如使用在 <table id="list" class="scroll" cellpadding="0" cellspacing="0"></table> <div id="pager" class="scroll" style="text-align:center;"></div> jqGrid裡的定義加上 onSelectRow: function (id) { if (id && id !== lastsel) { if (lastrow != null) { jQuery.fn.fmatter.rowactions.call(lastrow.find('.ui-inline-cancel'), 'cancel'); } jQuery.fn.fmatter.rowactions.call($('#list').find('tr:hover').find('.ui-inline-edit'), 'edit'); lastsel = id; lastrow = $('#list').find('tr:hover'); } }, 以及 jQuery('#list').jqGrid('navGrid', "#pager", { edit: false, add: false, del: false, search: true, refresh: true }, {}, // default settings for edit {}, // default settings for add {}, // default settings for delete { closeOnEscape: true, multipleSearch: true, closeAfterSearch: true }, // search options {} ); jQuery("#list").jqGrid('inlineNav', "#pager", { edit: false, add: true, save: false, cancel: false, addParams: {useFormatter: true} } ); </pre> *預設的按鈕圖是採用 jQuery UI的 icon 圖,它顯示的Size是16x16px,如果要放大的話 <source lang="css"> div.ui-pg-div { width: 28px; height: 28px; } span.ui-icon { zoom:1.6; -moz-transform:scale(1.6); -moz-transform-origin: 0 0; } </source> ===jqGrid與Search=== *[http://www.codeproject.com/Articles/58357/Using-jqGrid-s-search-toolbar-with-multiple-filter Using jqGrid’s search toolbar with multiple filters in ASP.NET MVC] ** [[MvcGrid.Models]] *[http://stackoverflow.com/questions/5500805/asp-net-mvc-2-0-implementation-of-searching-in-jqgrid ASP.NET MVC 2.0 Implementation of searching in jqgrid] *[http://tpeczek.codeplex.com/releases/view/62741 jqGrid in ASP.NET MVC - Strongly typed helper] ===jqGrid與Autocomplete=== *[http://stackoverflow.com/questions/13932264/jqgrid-autocomplete JqGrid + Autocomplete] *[http://germanrumm.eu/adding-jqueryui-autocomplete-to-jqgrid-edit-form/ Adding jQueryUI Autocomplete to jqGrid edit form] ===jqGrid與Validation=== *[http://stackoverflow.com/questions/1937807/jquery-validation-plugin-with-jqgrid jQuery Validation plugin with JQGrid?] ===自訂在inline編輯模式下要回傳給Server儲存的變數=== <source lang="javascript"> $.jgrid.inlineEdit = $.extend(true, $.jgrid.inlineEdit,{ extraparam: { 變數名: 變數值 } }); </source> ===自訂擴充=== ;$.jgrid.defaults <source lang="javascript"> $.jgrid.defaults = = $.extend($.jgrid.inlineEdit, { url: "", height: 150, page: 1, rowNum: 20, rowTotal : null, records: 0, pager: "", pgbuttons: true, pginput: true, colModel: [], rowList: [], colNames: [], sortorder: "asc", sortname: "", datatype: "xml", mtype: "GET", altRows: false, selarrrow: [], savedRow: [], shrinkToFit: true, xmlReader: {}, jsonReader: {}, subGrid: false, subGridModel :[], reccount: 0, lastpage: 0, lastsort: 0, selrow: null, beforeSelectRow: null, onSelectRow: null, onSortCol: null, ondblClickRow: null, onRightClickRow: null, onPaging: null, onSelectAll: null, onInitGrid : null, loadComplete: null, gridComplete: null, loadError: null, loadBeforeSend: null, afterInsertRow: null, beforeRequest: null, beforeProcessing : null, onHeaderClick: null, viewrecords: false, loadonce: false, multiselect: false, multikey: false, editurl: null, search: false, caption: "", hidegrid: true, hiddengrid: false, postData: {}, userData: {}, treeGrid : false, treeGridModel : 'nested', treeReader : {}, treeANode : -1, ExpandColumn: null, tree_root_level : 0, prmNames: {page:"page",rows:"rows", sort: "sidx",order: "sord", search:"_search", nd:"nd", id:"id",oper:"oper",editoper:"edit",addoper:"add",deloper:"del", subgridid:"id", npage: null, totalrows:"totalrows"}, forceFit : false, gridstate : "visible", cellEdit: false, cellsubmit: "remote", nv:0, loadui: "enable", toolbar: [false,""], scroll: false, multiboxonly : false, deselectAfterSort : true, scrollrows : false, autowidth: false, scrollOffset :18, cellLayout: 5, subGridWidth: 20, multiselectWidth: 20, gridview: false, rownumWidth: 25, rownumbers : false, pagerpos: 'center', recordpos: 'right', footerrow : false, userDataOnFooter : false, hoverrows : true, altclass : 'ui-priority-secondary', viewsortcols : [false,'vertical',true], resizeclass : '', autoencode : false, remapColumns : [], ajaxGridOptions :{}, direction : "ltr", toppager: false, headertitles: false, scrollTimeout: 40, data : [], _index : {}, grouping : false, groupingView : {groupField:[],groupOrder:[], groupText:[],groupColumnShow:[],groupSummary:[], showSummaryOnHide: false, sortitems:[], sortnames:[], summary:[],summaryval:[], plusicon: 'ui-icon-circlesmall-plus', minusicon: 'ui-icon-circlesmall-minus', displayField: []}, ignoreCase : false, cmTemplate : {}, idPrefix : "" }); </source> ;$.jgrid.inlineEdit <source lang="javascript"> $.jgrid.inlineEdit = $.extend($.jgrid.inlineEdit, { keys : false, oneditfunc: null, successfunc: null, url: null, extraparam: {}, aftersavefunc: null, errorfunc: null, afterrestorefunc: null, restoreAfterError: true, mtype: "POST" }); </source> [[Category:Grid]] [[Category:jQuery Plugin]]
返回到「
Jqgrid
」。
導覽選單
個人工具
建立帳號
登入
命名空間
頁面
討論
臺灣正體
視圖
閱讀
檢視原始碼
檢視歷史
更多
搜尋
導覽
首頁
近期變更
隨機頁面
MediaWiki說明
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊