我有一個dojox.grid.DataGrid
。在該正在與最後2列被填滿了,其根據在gridStruture
使用formatter
屬性從數據庫被檢索數據動態創建buttons
顯示一組值的沿。現在我得到了我的網格很好。按鈕也很好。我現在需要做的是當我點擊該按鈕上的特定按鈕時,單擊事件,我將其重定向到一個具有特定值(A)的新URL,作爲該URL中的查詢字符串參數傳遞。我不希望我的頁面被刷新。就像點擊一個按鈕時,它會在其他某個JSP頁面上執行操作,並顯示消息alert("Action is being performed")
。在那裏我有編碼爲我的數據網格執行操作按鈕單擊事件,按鈕被放置在dojox.grid.DataGrid內。
我的Java腳本代碼::
<script type="text/javascript">
function getInfoFromServer(){
$.get("http://localhost:8080/2_8_2012/jsp/GetJson.jsp?random=" + new Date().getTime(), function (result) {
success:postToPage(result),
alert('Load was performed.');
},"json");
}
function postToPage(data){
alert(data);
var storedata = {
identifier:"ActID",
items: data
};
alert(storedata);
var store1 = new dojo.data.ItemFileWriteStore({data: storedata}) ;
var gridStructure =[[
{ field: "ActID",
name: "Activity ID",
classes:"firstName"
},
{
field: "Assigned To",
name: "Assigned To",
classes: "firstName"
},
{ field: "Activity Type",
name: "Activity Type",
classes:"firstName"
},
{
field: "Status",
name: "Status",
classes: "firstName"
},
{
field: "Assigned Date",
name: "Assigned Date",
classes: "firstName"
},
{
field: "Assigned Time",
name: "Assigned Time",
classes: "firstName"
},
{
field: "Email",
name: "Send Mail",
formatter: sendmail,
classes: "firstName"
},
{
field: "ActID",
name: "Delete",
formatter: deleteact,
classes: "firstName"
}
]
];
//var grid = dijit.byId("gridDiv");
//grid.setStore(store1);
var grid = new dojox.grid.DataGrid({
store: store1,
structure: gridStructure,
rowSelector: '30px',
selectionMode: "single",
autoHeight:true,
columnReordering:true
},'gridDiv');
grid.startup();
dojo.connect(grid, "onRowClick", grid, function(){
var items = grid.selection.getSelected();
dojo.forEach(items, function(item){
var v = grid.store.getValue(item, "ActID");
getdetailsfordialog(v);
function showDialog() {
dojo.require('dijit.Tooltip');
dijit.byId("terms").show();
}
showDialog();
}, grid);
});
}
function sendmail(item) {
alert(item);
return "<button onclick=http://localhost:8080/2_8_2012/jsp/SendMailReminder.jsp?Send Mail="+item+"'\">Send Mail</button>";
}
function deleteact(item) {
alert(item);
return "<button onclick=http://localhost:8080/2_8_2012/jsp/DeleteActivity.jsp?Activity ID="+item+"'\">Delete</button>";
}
</script>
我正在使用$.get
調用網格數據。在上述代碼字段Email
和ActID
實際上是在每個時間函數sendmail
和deleteact
在formatter
中被調用時創建的按鈕。網格顯示。兩個函數中的值alert(item)
都是正確的,這就是各自的值。像在Delete
alert(item)
我在sendmail
越來越"[email protected]"
越來越ActID
和alert(item)
現在,我想,在一個特定的button click
(在Sendmail
欄按鈕),我的網頁
http://localhost:8080/2_8_2012/jsp/SendMailReminder.jsp?Send Mail="+item+"'
和button click
在Delete
列本頁面
http://localhost:8080/2_8_2012/jsp/DeleteActivity.jsp?Activity ID="+item+"'\"
用從數據庫檢索的項目的值打開。我已經申請了一個rowClick
事件也這也造成問題,因爲當我點擊你的按鈕我的Rowclick
事件觸發,而不是按鈕點擊事件。這個怎麼做。我想到將點擊事件應用到網格上的每個按鈕。但是我不知道那裏有身份證。請幫我解決這個問題。謝謝..
你是什麼意思'執行一些其他的JSP頁面上行動'?你想在彈出窗口中打開這個其他的JSP,還是發送一個Ajax請求來執行一些服務器端的動作或其他什麼? – ivalkeen 2012-04-22 18:23:01
在那個JSP SendMailReminder.jsp。我有一個類的對象發送郵件。這個對象調用一個類的特定函數,它將一個郵件發送到從查詢字符串中的項目中收集的值。所以基本上我需要將這個值作爲參數傳遞給SendMailReminder.jsp中的被調用函數。或者我可以做的是隻在同一頁面上調用該方法,而不將其重定向到SendMailReminder.jsp。如果第二個可能,請給我一個方法來做到這一點?謝謝 – 2012-04-23 04:25:41
而且,我一直在收到一個錯誤「試圖註冊一個id =」的東西,但該ID已經註冊「。我知道它是一個非常常見的錯誤,並且可以從dojo註冊表中刪除id。但我不清楚它是什麼。以及如何克服這一點。謝謝..我不接受我當前頁面中的這個錯誤(Ques被問到)。但不斷在其他網頁上獲得它。 – 2012-04-23 04:38:06