jgcoffey
asked on
How do I implement a Select All check box for Dojo v1.4.3 AdvancedDataGrid
I need to add a select all check box to the DataGrid checkbox column and code to programmatically check the boxes in the following jsp code
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="true"%>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/Grid.css" />
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/claroGrid.css" />
<portlet:defineObjects/>
<script language="javascript" data-dojo-config="isDebug: true,parseOnLoad: true">
dojo.require("dojox.grid.D ataGrid");
dojo.require("dojo.data.It emFileWrit eStore");
dojo.require("dojox.grid.E nhancedGri d");
dojo.require("dojox.grid.e nhanced.pl ugins.Indi rectSelect ion");
dojo.require("dijit.form.B utton");
dojo.ready(init);
var addPoliciesGrid;
var addPoliciesStore;
// set the layout structure:
var addPoliciesLayout = [
{
field : 'policyNumber',
name : 'Policy #',
width : '70px'
}, {
field : 'billing',
name : 'Billing',
width : '90px'
}, {
field : 'owner',
name : 'Owner',
width : '80px'
}, {
field : 'insured',
name : 'Insured',
width : '80px'
}, {
field : 'paidTo',
name : 'Paid to',
width : '70px'
}, {
field : 'amount',
name : 'Amount',
width : '70px'
} ];
function init() {
initalizeAddPoliciesStore( );
}
function initalizeAddPoliciesStore( ) {
addPoliciesStore = new dojo.data.ItemFileWriteSto re(
{
url : "http://localhost:10039/ProduceJSONWeb/servlet/com.mycompany.servlet.ReturnJson"
});
addPoliciesGrid = new dojox.grid.EnhancedGrid({
id : 'addPoliciesGrid',
plugins: {indirectSelection: true},
query : {
policyNumber : '*'
},
store : addPoliciesStore,
structure : addPoliciesLayout
}, 'addPoliciesGridTableId');
addPoliciesGrid.startup();
}
function displayAllCheckedPolicyNum ber(){
addPoliciesGrid.store.fetc h({
onComplete: function (items) {
dojo.forEach(items, function (item, rowIndex){
if(addPoliciesGrid.selecti on.selecte d[rowIndex ]){
console.debug("rowIndex = "+rowIndex + " Policy # = "+item.policyNumber);
}
});
}
});
}
//http://dojotoolkit.org/reference-guide/dojox/grid/EnhancedGrid.html#dojox-grid-enhancedgrid
</script>
<div id="addPolicies" style="height:200px">
<table id="addPoliciesGridTableId " dojotype="dojox.grid.DataG rid"></tab le>
</div>
<div id="showSelectedButton">
<button onClick="displayAllChecked PolicyNumb er()">Show all checked Policy#</button>
</div>
<%@page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1" session="true"%>
<%@taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dijit/themes/claro/claro.css" />
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/Grid.css" />
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/dojo/1.5/dojox/grid/resources/claroGrid.css" />
<portlet:defineObjects/>
<script language="javascript" data-dojo-config="isDebug:
dojo.require("dojox.grid.D
dojo.require("dojo.data.It
dojo.require("dojox.grid.E
dojo.require("dojox.grid.e
dojo.require("dijit.form.B
dojo.ready(init);
var addPoliciesGrid;
var addPoliciesStore;
// set the layout structure:
var addPoliciesLayout = [
{
field : 'policyNumber',
name : 'Policy #',
width : '70px'
}, {
field : 'billing',
name : 'Billing',
width : '90px'
}, {
field : 'owner',
name : 'Owner',
width : '80px'
}, {
field : 'insured',
name : 'Insured',
width : '80px'
}, {
field : 'paidTo',
name : 'Paid to',
width : '70px'
}, {
field : 'amount',
name : 'Amount',
width : '70px'
} ];
function init() {
initalizeAddPoliciesStore(
}
function initalizeAddPoliciesStore(
addPoliciesStore = new dojo.data.ItemFileWriteSto
{
url : "http://localhost:10039/ProduceJSONWeb/servlet/com.mycompany.servlet.ReturnJson"
});
addPoliciesGrid = new dojox.grid.EnhancedGrid({
id : 'addPoliciesGrid',
plugins: {indirectSelection: true},
query : {
policyNumber : '*'
},
store : addPoliciesStore,
structure : addPoliciesLayout
}, 'addPoliciesGridTableId');
addPoliciesGrid.startup();
}
function displayAllCheckedPolicyNum
addPoliciesGrid.store.fetc
onComplete: function (items) {
dojo.forEach(items, function (item, rowIndex){
if(addPoliciesGrid.selecti
console.debug("rowIndex = "+rowIndex + " Policy # = "+item.policyNumber);
}
});
}
});
}
//http://dojotoolkit.org/reference-guide/dojox/grid/EnhancedGrid.html#dojox-grid-enhancedgrid
</script>
<div id="addPolicies" style="height:200px">
<table id="addPoliciesGridTableId
</div>
<div id="showSelectedButton">
<button onClick="displayAllChecked
</div>
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
The solution did not completely solve my problem but it looks like the solution I require is not going to delivered to me. It seems like Experts Exchange does not recognize Dojo as a zone so it is difficult to find the target audience I require to answer this solution. I currently regret that I paid a full year subscription
to this service based on another users recommendation.
to this service based on another users recommendation.
ASKER