如何关闭dojox.grid.DataGrid
我有一个从搜索事件填充的网格,我希望能够通过在右上角添加一个X来关闭网格,类似于关闭任何浏览器或窗口的方式。我想这就像添加X一样简单,根据我的喜好设计它的样式,然后创建一个onclick事件来关闭或隐藏网格。。。但我似乎无法让它工作。任何帮助都将不胜感激 我的JS是:如何关闭dojox.grid.DataGrid,dojo,dojox.grid.datagrid,Dojo,Dojox.grid.datagrid,我有一个从搜索事件填充的网格,我希望能够通过在右上角添加一个X来关闭网格,类似于关闭任何浏览器或窗口的方式。我想这就像添加X一样简单,根据我的喜好设计它的样式,然后创建一个onclick事件来关闭或隐藏网格。。。但我似乎无法让它工作。任何帮助都将不胜感激 我的JS是: dojo.require("dojox.grid.DataGrid"); //FindTask dojo.require("dojo.data.ItemFileReadStore"); //FindTask dojo.requir
dojo.require("dojox.grid.DataGrid"); //FindTask
dojo.require("dojo.data.ItemFileReadStore"); //FindTask
dojo.require("esri.tasks.find"); //FindTask
var findTask, findParams;
var grid, store;
var searchExtent;
function doFind() {
//Show datagrid onclick of search button and resize the map div.
esri.show(datagrid);
dojo.style(dojo.byId("content"), "height", "83%");
searchExtent = new esri.geometry.Extent ({
"xmin":-9196258.30121186,"ymin":3361222.57748752,"xmax":-9073959.055955742,"ymax":3442169.390441412,"spatialReference":{"wkid":102100}
});
map.setExtent(searchExtent);
//Set the search text to the value in the box
findParams.searchText = dojo.byId("parcel").value;
grid.showMessage("Loading..."); //Shows the Loading Message until search results are returned.
findTask.execute(findParams,showResults);
}
function showResults(results) {
//This function works with an array of FindResult that the task returns
map.graphics.clear();
var symbol = new esri.symbol.SimpleFillSymbol(esri.symbol.SimpleFillSymbol.STYLE_SOLID, new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID, new dojo.Color([98,194,204]), 2), new dojo.Color([98,194,204,0.5]));
//create array of attributes
var items = dojo.map(results,function(result){
var graphic = result.feature;
graphic.setSymbol(symbol);
map.graphics.add(graphic);
return result.feature.attributes;
});
//Create data object to be used in store
var data = {
identifier: "Parcel Identification Number", //This field needs to have unique values. USES THE ALIAS!!!
label: "PARCELID", //Name field for display. Not pertinent to a grid but may be used elsewhere.
items: items
};
//Create data store and bind to grid.
store = new dojo.data.ItemFileReadStore({ data:data });
var grid = dijit.byId('grid');
grid.setStore(store);
//Zoom back to the initial map extent
map.setExtent(searchExtent);
}
//Zoom to the parcel when the user clicks a row
function onRowClickHandler(evt){
var clickedTaxLotId = grid.getItem(evt.rowIndex).PARCELID;
var selectedTaxLot;
dojo.forEach(map.graphics.graphics,function(graphic){
if((graphic.attributes) && graphic.attributes.PARCELID === clickedTaxLotId){
selectedTaxLot = graphic;
return;
}
});
var taxLotExtent = selectedTaxLot.geometry.getExtent();
map.setExtent(taxLotExtent);
}
我的HTML是:
<div id ="datagrid" data-dojo-type="dijit.layout.AccordionPane" splitter="true" region="bottom"
style="width:100%; height:125px;">
<table data-dojo-type="dojox.grid.DataGrid" data-dojo-id="grid" id="grid" data-dojo-props="rowsPerPage:'5', rowSelector:'20px'">
<thead>
<tr>
<th field="Parcel Identification Number" width="10%">
Parcel ID
</th>
<th field="Assessing Neighbornood Code" width ="20%">
Neighborhood Code
</th>
<th field="Property Class Code" width="10%">
Property Class
</th>
<th field="Site Address" width="100%">
Address
</th>
</tr>
</thead>
</table>
</div>
包裹ID
邻域码
属性类
地址
这是我对添加内容的最佳猜测:
<tr>
<td align="right">
<div class="divOk" onclick="dijit.byId('tocDiv').hide();">
OK</div>
</td>
</tr>
好啊
这个怎么样?
(假设OK行实际出现)
HTML
<tr>
<td align="right">
<div class="divOk" onclick="hideGrid();">OK</div>
</td>
</tr>
这个怎么样?
(假设OK行实际出现)
HTML
<tr>
<td align="right">
<div class="divOk" onclick="hideGrid();">OK</div>
</td>
</tr>
最后,我创建了一个新的列,并在标题中放置了一个关闭图标,从而为我想要的内容创建了一个变通方法。我将其连接到一个函数,这样当我单击它时,网格将关闭,贴图将调整大小:
function closeGrid() {
esri.hide(datagrid);
dojo.style("map", {"height": "100%"});
}
HTML
我通过创建一个新列并在标题中放置一个关闭图标,为我想要的内容创建了一个变通方法。我将其连接到一个函数,这样当我单击它时,网格将关闭,贴图将调整大小:
function closeGrid() {
esri.hide(datagrid);
dojo.style("map", {"height": "100%"});
}
HTML
我看不到您在代码中尝试实现目标的内容。编辑以包含我的尝试…我看不到您在代码中尝试实现目标的内容。编辑以包含我的尝试…Alright已经想知道它会如何。我可以告诉您,DataGrid
的声明性实例是伪造的。实际上,DataGrid
由各种div
组成,但没有任何表(如您所见,如果您查找解析的源代码)。我想最简单的方法是,将整个DataGrid
包装在另一个div
中,您可以在其中放置X
。根据您的用例,考虑在dijit中显示DataGrid
也是值得的。Dialog
-widget…alrigth已经想知道它会是什么样子。我可以告诉您,DataGrid
的声明性实例是伪造的。实际上,DataGrid
由各种div
组成,但没有任何表(如您所见,如果您查找解析的源代码)。我想最简单的方法是,将整个DataGrid
包装在另一个div
中,您可以在其中放置X
。根据您的用例,考虑在dijit.Dialog
-widget中向您显示DataGrid
也是值得的。。。