2012-03-06 7 views
0

dojox.grid.DataGridというグリッド内で、うまく動作しているいくつかの値のセットが表示されています。今私は新しいJSPページにリダイレクトする特定の行をクリックするようなイベントを実行したい。それとも私が何かできることができる窓を開くでしょう。どうやってするか ?私を助けてください。ありがとう。dojox.grid.DataGridの擬似行を選択する際にイベントを実行します。

コードがある::あなたのonready機能で

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" 
    pageEncoding="ISO-8859-1"%> 
<%@ page import="MyPackage.PopulateTextbox" %> 
<%@ page import="java.sql.*" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<style type="text/css"> 
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.7/dojo/resources/dojo.css"; 
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.7/dijit/themes/nihilo/nihilo.css"; 
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.7/dojox/grid/resources/Grid.css"; 
    @import "http://ajax.googleapis.com/ajax/libs/dojo/1.7/dojox/grid/resources/nihiloGrid.css"; 

</style> 

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.7/dojo/dojo.js" djConfig="isDebug: false, parseOnLoad: true"></script> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> 
<script type="text/javascript"> 

dojo.require("dojox.grid.DataGrid"); 
dojo.require("dojo.data.ItemFileReadStore"); 
dojo.require("dojo.data.ItemFileWriteStore"); 
</script> 
<% 
String temp1; 
PopulateTextbox obj = new PopulateTextbox(); 
temp1 = obj.method(); 
request.setAttribute("variable", temp1); 
%> 

<script type="text/javascript"> 
dojo.ready(function(){ 
var myVar = <%= request.getAttribute("variable") %> 
var storedata={ 
      identifier:"ID", 
      label:"name", 
      items: myVar 
    }; 

var store = new dojo.data.ItemFileWriteStore({data: storedata}); 

    var gridStructure =[[ 

         { field: "ID", 
          name: "ID_Emp", 
          width: "40%" 
         }, 
         { 
          field: "Names", 
          name: "Name", 
          width: "40%" 
         } 

       ] 
      ]; 


    var grid = new dojox.grid.DataGrid({ 
      id: 'grid', 
      store: store, 
      structure: gridStructure, 
      }, 
      document.createElement('div')); 

     /*append the new grid to the div*/ 
     dojo.byId("gridDiv").appendChild(grid.domNode); 

     /*Call startup() to render the grid*/ 
     grid.startup(); 
}); 
</script> 

<title>Dojo Data</title> 
</head> 
<body> 
<div id="gridDiv" dojoType="dojox.grid.DataGrid" title="Simple Grid" style="width:1000px; height:500px;"> 
</div> 


</body> 
</html> 

答えて

1

、grid.startup後、次の操作を行います。 http://dojotoolkit.org/documentation/tutorials/1.6/working_grid/

API:で

dojo.connect(grid, "onRowClick", grid, function(evt){ 
    var idx = evt.rowIndex, 
     item = this.getItem(idx); 

    // get the ID attr of the selected row 
    var value = this.store.getValue(item, "ID"); 

    //open a dialog or new window or redirect to new JSP 

    //to redirect to new jsp, you can set window.location.href to the new url 

    //to open a new dialog, i suggest using dijit.dialog 
    //see: http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/test_Dialog.html 

    //to open a new window, use window.open 
    //http://www.pageresource.com/jscript/jwinopen.htm 
}); 

以上のグリッドの例をdocは可能なすべてのイベントをリストします: http://dojotoolkit.org/api/1.6/dojox/grid/DataGrid#onApplyCellEdit

関連する問題