Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537 Warning: error_log(/data/www/wwwroot/hmttv.cn/caches/error_log.php): failed to open stream: Permission denied in /data/www/wwwroot/hmttv.cn/phpcms/libs/functions/global.func.php on line 537
于具有很多屬性的標(biāo)簽,我希望在新行上分割每個(gè)屬性,當(dāng)按Enter鍵調(diào)用新行時(shí),它應(yīng)該只縮進(jìn)一個(gè)標(biāo)簽。
以下示例輸出我想如何縮進(jìn)我的屬性:
<svg width="300px" height="150px"> <ellipse class="fill-current" cx="150" cy="75" rx="100" ry="75" /> </svg>
但PHPStorm會(huì)自動(dòng)嘗試將我所有的行縮進(jìn)到當(dāng)前屬性:
<svg width="300px" height="150px"> <ellipse class="fill-current" cx="150" cy="75" rx="100" ry="75" /> </svg>
我無法在設(shè)置(編輯器 - >代碼樣式 - > HTML)中找到任何選項(xiàng)來更改此行為。有誰知道這個(gè)問題的解決方案?
這背后的原因是因?yàn)槲医?jīng)常在我的HTML模板中使用自定義標(biāo)簽。有時(shí)候我自己的標(biāo)簽很長,并且是2個(gè)或(罕見的情況下)3個(gè)單詞的組合,并且在新行上啟動(dòng)所有額外屬性并且它不應(yīng)該在標(biāo)簽的末尾對(duì)齊。自己縮進(jìn)屬性是很麻煩的。我想自動(dòng)化它。
.引用相關(guān)頭文件
引入CSS:
<link href="Scripts/jquery-ui-1.8.1.custom.css" rel="stylesheet" type="text/css" />
<link href="Scripts/ui.jqgrid.css" rel="stylesheet" type="text/css" />
引入JS:
<script src="Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="Scripts/jquery-ui.min.js" type="text/javascript"></script>
<script src="Scripts/grid.locale-en.js" type="text/javascript"></script>
<script src="Scripts/jquery.jqGrid.min.js" type="text/javascript"></script>
因?yàn)閖qGrid3.6及以后的版本集成了jQuery UI,所以,此處需要導(dǎo)入U(xiǎn)I相關(guān)js和css。另外grid.locale-en.js這個(gè)語言文件必須在jquery.jqGrid.min.js之前加載,否則會(huì)出問題。
2.將jqgrid加入頁面中
根據(jù)jqGrid的文檔,要想生成一個(gè)jqGrid,最直接的方法就是:
$("#list").jqGrid(options);
其中l(wèi)ist是頁面上的一個(gè)table:<table id="list"></table>
下面是一個(gè)簡單的例子:
<script type="text/javascript">
$(document).ready(function () {
jQuery("#list").jqGrid({
url: 'Handler.ashx',
datatype: "json",
mtype: 'GET',
colNames: ['SalesReasonID', 'Name', 'ReasonType', 'ModifiedDate'],
colModel: [
{ name: 'SalesReasonID', index: 'SalesReasonID', width: 40, align: "left", editable: true },
{ name: 'Name', index: 'Name', width: 100, align: "center" },
{ name: 'ReasonType', index: 'ReasonType', width: 100, align: "center" },
{ name: 'ModifiedDate', index: 'ModifiedDate', width: 150, align: "center", search: false }
],
rowList: [10, 20, 30],
sortname: 'SalesReasonID',
viewrecords: true,
sortorder: "desc",
jsonReader: {
root: "griddata",
total: "totalpages",
page: "currpage",
records: "totalrecords",
repeatitems: false
},
pager: jQuery('#pager'),
rowNum: 5,
altclass: 'altRowsColour',
//width: 'auto',
width: '500',
height: 'auto',
caption: "DemoGrid"
}).navGrid('#pager', { add: true, edit: true, del: true,search:false,refresh:false }); ;
})
二、 jqgrid的重要選項(xiàng)
具體的options參考,可以訪問jqGrid文檔關(guān)于option的章節(jié)(http://www.trirand.com/jqgridwiki/doku.php?id=wiki:options)。其中有幾個(gè)是比較常用的,重點(diǎn)介紹一下:
2.1 prmNames選項(xiàng)
prmNames是jqGrid的一個(gè)重要選項(xiàng),用于設(shè)置jqGrid將要向Server傳遞的參數(shù)名稱。其默認(rèn)值為:
prmNames : {
page:"page", // 表示請(qǐng)求頁碼的參數(shù)名稱
rows:"rows", // 表示請(qǐng)求行數(shù)的參數(shù)名稱
sort: "sidx", // 表示用于排序的列名的參數(shù)名稱
order: "sord", // 表示采用的排序方式的參數(shù)名稱
search:"_search", // 表示是否是搜索請(qǐng)求的參數(shù)名稱
nd:"nd", // 表示已經(jīng)發(fā)送請(qǐng)求的次數(shù)的參數(shù)名稱
id:"id", // 表示當(dāng)在編輯數(shù)據(jù)模塊中發(fā)送數(shù)據(jù)時(shí),使用的id的名稱
oper:"oper", // operation參數(shù)名稱
editoper:"edit", // 當(dāng)在edit模式中提交數(shù)據(jù)時(shí),操作的名稱
addoper:"add", // 當(dāng)在add模式中提交數(shù)據(jù)時(shí),操作的名稱
deloper:"del", // 當(dāng)在delete模式中提交數(shù)據(jù)時(shí),操作的名稱
subgridid:"id", // 當(dāng)點(diǎn)擊以載入數(shù)據(jù)到子表時(shí),傳遞的數(shù)據(jù)名稱
npage: null,
totalrows:"totalrows" // 表示需從Server得到總共多少行數(shù)據(jù)的參數(shù)名稱,參見jqGrid選項(xiàng)中的rowTotal
}
2.2 jsonReader選項(xiàng)
jsonReader是jqGrid的一個(gè)重要選項(xiàng),用于設(shè)置如何解析從Server端發(fā)回來的json數(shù)據(jù),如果Server返回的是xml數(shù)據(jù),則對(duì)應(yīng)的使用xmlReader來解析。jsonReader的默認(rèn)值為:
jsonReader : {
root: "rows", // json中代表實(shí)際模型數(shù)據(jù)的入口
page: "page", // json中代表當(dāng)前頁碼的數(shù)據(jù)
total: "total", // json中代表頁碼總數(shù)的數(shù)據(jù)
records: "records", // json中代表數(shù)據(jù)行總數(shù)的數(shù)據(jù)
repeatitems: true, // 如果設(shè)為false,則jqGrid在解析json時(shí),會(huì)根據(jù)name來搜索對(duì)應(yīng)的數(shù)據(jù)元素(即可以json中元素可以不按順序);而所使用的name是來自于colModel中的name設(shè)定。
cell: "cell",
id: "id",
userdata: "userdata",
subgrid: {
root:"rows",
repeatitems: true,
cell:"cell"
}
}
假如有下面一個(gè)json字符串:
{"totalpages":"3","currpage":"1","totalrecords":"11","griddata":[{"SalesReasonID":"1","Name":"Price","ReasonType":"Other","ModifiedDate":"1998年6月1日"},{"SalesReasonID":"2","Name":"On Promotion","ReasonType":"Promotion","ModifiedDate":"1998年6月1日"},{"SalesReasonID":"3","Name":"Magazine Advertisement","ReasonType":"Marketing","ModifiedDate":"1998年6月1日"},{"SalesReasonID":"4","Name":"Television Advertisement","ReasonType":"Marketing","ModifiedDate":"1998年6月1日"},{"SalesReasonID":"5","Name":"Manufacturer","ReasonType":"Other","ModifiedDate":"1998年6月1日"}]}
其對(duì)應(yīng)的jsonReader為:jsonReader: {
root: "griddata",
total: "totalpages",
page: "currpage",
records: "totalrecords",
repeatitems: false
}
注:cell、id在repeatitems為true時(shí)可以用到,即每一個(gè)記錄是由一對(duì)id和cell組合而成,即可以適用另一種json結(jié)構(gòu)。援引文檔中的例子:
repeatitems為true時(shí):
jQuery("#gridid").jqGrid({
...
jsonReader : {
root:"invdata",
page: "currpage",
total: "totalpages",
records: "totalrecords"
},
...
});
json結(jié)構(gòu)為:
{
"totalpages": "xxx",
"currpage": "yyy",
"totalrecords": "zzz",
"invdata" : [
{"id" :"1", "cell" :["cell11", "cell12", "cell13"]}, // cell中不需要各列的name,只要值就OK了,但是需要保持對(duì)應(yīng)
{"id" :"2", "cell" :["cell21", "cell22", "cell23"]},
...
]
}
repeatitems為false時(shí):
jQuery("#gridid").jqGrid({
...
jsonReader : {
root:"invdata",
page: "currpage",
total: "totalpages",
records: "totalrecords",
repeatitems: false,
id: "0"
},
...
});
json結(jié)構(gòu)為:
{
"totalpages" : "xxx",
"currpage" : "yyy",
"totalrecords" : "zzz",
"invdata" : [
{"invid" : "1","invdate":"cell11", "amount" :"cell12", "tax" :"cell13", "total" :"1234", "note" :"somenote"}, // 數(shù)據(jù)中需要各列的name,但是可以不按列的順序
{"invid" : "2","invdate":"cell21", "amount" :"cell22", "tax" :"cell23", "total" :"2345", "note" :"some note"},
...
]
}
2.3 colModel的重要選項(xiàng)
colModel也有許多非常重要的選項(xiàng),在使用搜索、排序等方面都會(huì)用到。這里先只說說最基本的。
三、 注意事項(xiàng)
1. 動(dòng)態(tài)改變Add Form或者Edit Form中的select的內(nèi)容,如:改變下圖中的Comparator下拉中的內(nèi)容。
$("#list_d").navGrid('#pager_d',{add:true,edit:true,del:true,search:false,refresh:false},
{
checkOnSubmit:false, closeAfterEdit: true,recreateForm:true,
beforeInitData:function(formid){
initComparator();
},
beforeShowForm: function(formid){
$("#list_d").jqGrid('setColProp', 'Name', { editrules:{required:false},});
$('#tr_Name', formid).hide();
}
},//edit
{},//add
{}//del
)
beforeInitData, beforeShowForm在每次點(diǎn)擊編輯的時(shí)候都會(huì)執(zhí)行。initComparator的作用是通過ajax獲取數(shù)據(jù),然后利用$("#list_d").jqGrid('setColProp', 'Comparator', { editoptions: { value: valueString} });來設(shè)置Comparator下拉中的內(nèi)容。其中valueString的格式如下’ equal to: equal to; not equal to: not equal to’。鍵值之間用冒號(hào)隔開,2項(xiàng)之間用分號(hào)隔開。注意:把recreateForm設(shè)為true,否則'setColProp'只在第一次調(diào)用時(shí)有效。
2. var rowNum = parseInt($(this).getGridParam("records"), 10); 得到數(shù)據(jù)條數(shù)。
3. jQuery("#list_d").clearGridData();清空數(shù)據(jù)。
4. jQuery("#list").getCell(ids,"Key");獲取第ids行的key列。
5. $("#list").jqGrid('setSelection', "1");選中第一行。放在loadComplete:中在gird加載完成的時(shí)候自動(dòng)選中第一行。loadComplete:function(data){$("#list").jqGrid('setSelection', "1");
}
6. 對(duì)于像1中的可編輯的字段,可以設(shè)定rule,參見http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules#editrules
7. 修改Option,以URL為例
jQuery("#list_d").jqGrid('setGridParam',{url:"xxx.aspx",page:1}).trigger('reloadGrid');
inymce是一個(gè)免費(fèi)的WYSIWYG HTML編輯器,由JavaScript寫成。它是一個(gè)根據(jù)LGPL license發(fā)布的自由軟件。Tinymce可以將文本區(qū)轉(zhuǎn)換為富文本HTML編輯器,并可以嵌入到PHP腳本。
NicEdit是一款輕量級(jí)的、跨平臺(tái)的編輯器,具有強(qiáng)大的功能來編輯HTML內(nèi)容。NicEdit能夠讓任何 element/div變成可編輯或者能夠把標(biāo)準(zhǔn)的TextArea轉(zhuǎn)換成富文本編輯器。
Free BBCode Editor是一款免費(fèi)的WYSIWYG BBCode編輯器,可以插入到任何PHP腳本中。
OpenWebWare是一個(gè)跨瀏覽器,純JavaScript開發(fā),強(qiáng)大開源的WYSIWYG編輯器。支持多種瀏覽器和Web編程語言:PHP,ASP,ASP.net,Perl,Java,Cold Fusion。
Wyzz是一款基于GPL的免費(fèi)WYSIWYG編輯器。
widgEditor是一款輕量的、快速加載的富文本HTML WYSIWYG編輯器。它根據(jù)LGPL license發(fā)布。 widgEditor編輯器的外觀是比較個(gè)性的,尤其是文本域上邊的控制按鈕,比較與眾不同。
MarkitUp是一個(gè)輕量級(jí),可定制,靈活的WYSIWYG Editor,可實(shí)現(xiàn)非常強(qiáng)大的在線文本編輯器功能。可支持html、Wiki、BBScode等編輯格式,具體很強(qiáng)的擴(kuò)展性,使用非常方便。
TextAreaRich是一款免費(fèi)的、基于JavaScript的WYSIWYG編輯器 .它可以集成到Web應(yīng)用程序的PHP或ASP腳本中。
WYMeditor 是一個(gè)開源的、基于Web瀏覽器的可視化HTML編輯器。
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯
*請(qǐng)認(rèn)真填寫需求信息,我們會(huì)在24小時(shí)內(nèi)與您取得聯(lián)系。