所以我想設置細胞上的蒼蠅,但我有一些自定義格式爲我的網格,例如:與jqGrid的使用自定義格式setCell
formatter: function(cellvalue, options, rowObject) {
if (rowObject.myId){
return '<span class="editable" data-id="' + rowObject.myId + '">$' + cellvalue + '</span>';
}
else{
return cellvalue;
}
}
,並在電網完成後的一些點我想要做的事:
$('#table').jqGrid('setCell', 1,'colName', '500', 'test');
然而,問題是,這寫在格式化程序,只是用該單元格值替換整個事情。有沒有辦法通過自定義格式化程序或其他方式解決此問題?
樣本數據:
{"metaData":null,"records":[{"spendD1":2520.88,"spendD2":0,"cpaD1":11.95,"cpaD2":0,"conversionsD1":211,"conversionsD2":0,"conversionRateD1":11.00,"conversionRateD2":0.00,"clicksD1":1872,"clicksD2":0,"cpcD1":1.35,"cpcD2":0,"statusId":1,"statusName":"Active","creativesCount":0,"adGroupsCount":0,"keywordsCount":0,"queryTermsCountD1":0,"queryTermsCountD2":0,"trafficSourcesCount":0,"campaignId":6824,"adgroupId":151464,"adgroupName":".com General Credit Offers","bid":2.000}]}
編輯網格PARAMS:
所有的altRows
false
altclass
"ui-priority-secondary"
autoencode
false
autowidth
false
beforeProcessing
null
beforeSelectRow
null
caption
""
cellEdit
false
cellLayout
5
cellsubmit
"remote"
cmTemplate
Object {}
colModel
[Object { name="adgroupName", index="adgroupName", width=240, more...}, Object { name="campaignStatus", index="campaignStatus", width=60, more...}, Object { name="spendD1", index="spendD1", width=80, more...}, 8 more...]
colNames
["Ad Group", "Status", "Spend", 8 more...]
data
[]
datatype
"json"
deselectAfterSort
true
direction
"ltr"
disableClick
false
editurl
null
emptyrecords
"No records to view"
footerrow
true
forceFit
false
gridstate
"visible"
gridview
false
grouping
false
groupingView
Object { groupField=[0], groupOrder=[0], groupText=[0], more...}
headertitles
false
height
"100%"
hiddengrid
false
hidegrid
true
hoverrows
true
id
"advertiser_table"
idPrefix
""
ignoreCase
false
jsonReader
Object { root="records", page="pageNumber", total="totalPages", more...}
keyIndex
false
lastpage
1
lastsort
2
loadBeforeSend
null
loadError
null
loadonce
false
loadtext
"Loading..."
loadui
"enable"
localReader
Object { root="rows", page="page", total="total", more...}
mtype
"GET"
multiboxonly
false
multikey
false
multiselect
false
multiselectWidth
20
nv
0
onHeaderClick
null
onPaging
null
onRightClickRow
null
onSelectAll
null
onSelectRow
null
ondblClickRow
null
page
1
pager
""
pagerpos
"center"
pgbuttons
true
pginput
true
pgtext
"Page {0} of {1}"
postData
Object { _search=false, nd=1331821970112, rows=20, more...}
prmNames
Object { page="page", rows="rows", sort="sidx", more...}
reccount
2
recordpos
"right"
records
2
recordtext
"View {0} - {1} of {2}"
remapColumns
[]
resizeclass
""
rowList
[]
rowNum
20
rowTotal
null
rownumWidth
25
rownumbers
false
savedRow
[]
scroll
false
scrollOffset
18
scrollTimeout
40
scrollrows
false
search
false
selarrrow
[]
selrow
null
shrinkToFit
true
sortable
Object { update=function()}
sortname
"spendD1"
sortorder
"desc"
subGrid
false
subGridModel
[]
subGridWidth
20
tblwidth
1233
toolbar
[false, ""]
toppager
false
totaltime
9
treeANode
-1
treeGrid
false
treeGridModel
"nested"
treeReader
Object {}
tree_root_level
0
url
"/advertiser_services/amp/report/adgroup/get"
useProp
true
userData
Object { spendD1=2520.88, spendD2=0, cpaD1=11.95, more...}
userDataOnFooter
true
viewrecords
false
viewsortcols
[false, "vertical", true]
width
1233
im不知道這回答了這個問題。我知道如何獲得單元格值,但問題是我正在更改單元格的html結構,所以我失去了原始格式。 (我添加在一個輸入框,用戶可以輸入一個新的值爲單元格等)等即時通訊,即時通訊,我沒有放在rowObject id,而是一個不同的ID,來自我需要的服務器用於保存新的單元格值。 – Evan 2012-03-15 14:08:01
@Evan:在這種情況下,你必須按照最後一個建議與'children'。您應該發佈更多網格的完整定義。我如何解釋你是否知道使用'datatype'是很重要的:local或remote('xml','json'),不管你使用'loadonce:true'等等。所以,只需將您的問題附加到jqGrid的完整定義以及用於填充網格的數據示例中即可。 – Oleg 2012-03-15 14:22:25
添加了網格參數和一些示例數據 – Evan 2012-03-15 14:39:58