jqGrid自定義某列資料的值

2021-08-31 12:39:11 字數 1169 閱讀 2783

我們在使用grid的時候,經常遇到這樣的需求:

1.某列在後台伺服器返回的值不是客戶友好的,需要做轉換

2.某錶查詢出來的某列,只是乙個id,還需要聯查別的表,以顯示使用者友好的資料。但是如何再顯示到前台的grid呢?

以下是解決方案:

1.通過設定colmodel options  的editoptions :

示例:

jquery("#grid_id").jqgrid(, edittype:'select', formatter:'select', editable:true }, ... ] 

...

});

(editoptions的value還可以是乙個map——json格式的字串;edittype:'select', formatter:'select'的作用是,可以通過jqgrid自帶的formedit功能,進行新增和編輯時,可以以下拉框的形式體現)

2.通過json dot notation

when using json data with named values (i.e the repeatitems option is false) we can use so named dot notation and index notation.

for example, our colmodel definition might be as follows:

jquery("#gridid").jqgrid(,,,

,,

,},

}

],...

});

note the elements defined asname:'item.price' and name:'item.weight'

then our data:

, "note": "note", "stock": "0","ship": "1"}, 

,"ship": "2"},

,"ship":"3"},

] }

上面的官方示例中,需要顯示item的price和weight,那就要在我們後台**裡這麼寫,迭代各row,聯查item表,然後為item屬性賦物件值

jqGrid 自定義搜尋

jquery mysearch filtergrid grid id options options 引數 引數描述 預設值gridmodel 當為ture我們會使用colmodel中的屬性構造查詢條件,所用到的引數 name,index,edittype,editoptions,search.還有...

jqgrid編輯以及自定義

jqgrid可以有三種方式,讓我們來修改顯示在jqgrid中的資料。這三種方式分別是 cell editing 只允許修改某乙個單元格內容.所有均來自jqgrid的wiki或者jqgrid的demo截圖 inline editing 允許在jqgrid中直接修改某一行的資料 form editing...

自定義jqgrid 選單欄

經過再次研讀 發現其實修改自定義的選單欄的問題其實很簡單,就直接修改grid.locale cn.js檔案就可以了,在js中直接引用就好了,下面的內容看來是多餘的 直接看 recordtext 記錄 總記錄數 顯示記錄數的格式 emptyrecords 無資料 空記錄時的提示資訊 pgtext 頁數...