Reputation: 371
<script type="text/javascript">
var tbIndex = undefined
var tbData = undefined
$('#dg').datagrid({
onClickRow:function(rowIndex,rowData){
tbIndex = rowIndex
tbData = rowData
},
onClickCell:function(rowIndex,field,value)
{
if(field == 'type' || field == 'name' || field == 'card' || field == 'money')
{
var t = $('#dg').datagrid('selectRow',rowIndex)
console.log($(t).html())
ZeroClipboard.config({moviePath: "{{ URL::to('/') }}/images/ZeroClipboard.swf"})
//copy contents()
var client = new ZeroClipboard($('#dg').datagrid('selectRow',rowIndex));
client.on( 'load', function(client) {
//alert( "movie is loaded" );
client.on( 'datarequested', function(client) {
client.setText(this.innerHTML);
} );
client.on( 'complete', function(client, args) {
alert("copy complete:" + args.text );
} );
} );
}
}
})
I now want to implement click a column, copy the contents of a column
Upvotes: 0
Views: 3450
Reputation: 1695
Maybe you could do something like
$('#dg').datagrid({
onClickCell:function(rowIndex,field,value) {
var rows = $('#dg').datagrid('getRows');
var results = [];
for (var i=0; i<rows.length; i++) {
if (field == 'type') {
results[i] = rows[i].type;
} else if (field == 'name') {
results[i] = rows[i].name;
} else if (field == 'card') {
results[i] = rows[i].card;
} else if (field == 'money') {
results[i] = rows[i].money;
}
}
}
});
This will get you the values of rows of the same column as the cell you clicked.
Upvotes: 1