<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" Selectiontype="Multiple" AllowPaging="True">
<ToolbarSettings ShowToolbar="true" ToolbarItems="printGrid"></ToolbarSettings>
<Columns>
<ej:Column Field="OrderID" HeaderText="Order ID" TextAlign="Right" Width="75" />
<ej:Column Field="CustomerID" HeaderText="Customer ID" Width="80" />
<ej:Column Field="EmployeeID" HeaderText="Employee ID" TextAlign="Right" Width="75" />
<ej:Column Field="Freight" HeaderText="Freight" TextAlign="Right" Width="75" Format="{0:C}" />
<ej:Column Field="OrderDate" HeaderText="Order Date" TextAlign="Right" Width="80" Format="{0:MM/dd/yyyy}" />
<ej:Column Field="ShipCity" HeaderText="Ship City" Width="110" />
</Columns>
<ClientSideEvents ActionBegin="begin" BeforePrint="beforePrint" />
</ej:Grid>
<script type="text/javascript">
window.selectedRows = []; // window variable to store the selectedrecords while moving from one page to another
function printSelectedRows(selRows) {
if (!selectedRows.length) selectedRows = selRows;
else {
for (var sr = 0; sr < selRows.length; sr++) {
selectedRows.push(selRows[sr]);
}
}
}
function begin(args) {
if (args.requestType == "paging") {
if (this.getSelectedRows().length) {
var selRows = this.getSelectedRows();
printSelectedRows(selRows);
}
}
}
function beforePrint(args) {
var gridInst = $("#<%= FlatGrid.ClientID %>").ejGrid("instance");
var selRows = gridInst.getContentTable().find('tr[aria-selected="true"]');
if (selectedRows.length || selRows.length) {
if (selRows.length) printSelectedRows(selRows);
args.element.find(".e-gridcontent tbody tr").remove();
args.element.find(".e-gridcontent tbody").append(selectedRows);
gridInst.refreshContent();
}
}
</script> |
|
Hello
I have other problem. When prints for second ocassion, prints the actuality rows and preview rows.
<ej:Grid ID="FlatGrid" runat="server" AllowSorting="True" Selectiontype="Multiple" AllowPaging="True">
<ToolbarSettings ShowToolbar="true" ToolbarItems="printGrid"></ToolbarSettings>
………………………………………………….
<ClientSideEvents ActionBegin="begin" ActionComplete="complete" BeforePrint="beforePrint" />
</ej:Grid>
<script type="text/javascript">
window.selectedRows = []; // window variable to store the selectedrecords while moving from one page to another
function printSelectedRows(selRows) {
……………………………………….
}
function beforePrint(args) {
………………………………………………………
}
function complete(args){
if(args.requestType == "print"){
window.selectedRows = []; // clear the window variable
}
}
</script> |
function complete(args){
if(args.requestType == "print"){
window.selectedRows = []; // clear the window variable
}
|
function complete(args){
if(args.requestType == "print"){
windows.selectedRows = []; // clear the window variable
}
|
function complete(args){
if(args.requestType == "print"){
window.selectedRows = []; // clear the window variable
}
|