jQWidgets Forums
jQuery UI Widgets › Forums › Grid › jqx Grid
Tagged: jqxgrid
This topic contains 5 replies, has 2 voices, and was last updated by priyankajain 11 years, 11 months ago.
-
Authorjqx Grid Posts
-
Hello sir,
Please tell me how copy complete data from one grid to another grid on the clicking of a button and without selecting the rows in the grid.
Please give reply as soon as possible.
Regards
priyaHi priyankajain,
Please take a look at the following example:
<!DOCTYPE html><html lang="en"><head> <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" /> <script type="text/javascript" src="../../scripts/jquery-1.9.0.min.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script> <script type="text/javascript" src="../../scripts/gettheme.js"></script> <script type="text/javascript"> $(document).ready(function () { var theme = getDemoTheme(); $("#jqxButton").jqxButton({ width: '150' }); // prepare the data var data = new Array(); var firstNames = [ "Andrew", "Nancy", "Shelley", "Regina", "Yoshi", "Antoni", "Mayumi", "Ian", "Peter", "Lars", "Petra", "Martin", "Sven", "Elio", "Beate", "Cheryl", "Michael", "Guylene" ]; var lastNames = [ "Fuller", "Davolio", "Burke", "Murphy", "Nagase", "Saavedra", "Ohno", "Devling", "Wilson", "Peterson", "Winkler", "Bein", "Petersen", "Rossi", "Vileid", "Saylor", "Bjorn", "Nodier" ]; var productNames = [ "Black Tea", "Green Tea", "Caffe Espresso", "Doubleshot Espresso", "Caffe Latte", "White Chocolate Mocha", "Cramel Latte", "Caffe Americano", "Cappuccino", "Espresso Truffle", "Espresso con Panna", "Peppermint Mocha Twist" ]; var priceValues = [ "2.25", "1.5", "3.0", "3.3", "4.5", "3.6", "3.8", "2.5", "5.0", "1.75", "3.25", "4.0" ]; for (var i = 0; i < 200; i++) { var row = {}; var productindex = Math.floor(Math.random() * productNames.length); var price = parseFloat(priceValues[productindex]); var quantity = 1 + Math.round(Math.random() * 10); row["firstname"] = firstNames[Math.floor(Math.random() * firstNames.length)]; row["lastname"] = lastNames[Math.floor(Math.random() * lastNames.length)]; row["productname"] = productNames[productindex]; row["price"] = price; row["quantity"] = quantity; row["total"] = price * quantity; data[i] = row; } var source = { localdata: data, datatype: "array", datafields: [ { name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' }, { name: 'total', type: 'number' } ] }; var dataAdapter = new $.jqx.dataAdapter(source); $("#jqxgrid").jqxGrid( { width: 670, source: dataAdapter, theme: theme, columnsresize: true, columns: [ { text: 'Name', dataField: 'firstname', width: 100 }, { text: 'Last Name', dataField: 'lastname', width: 100 }, { text: 'Product', editable: false, dataField: 'productname', width: 180 }, { text: 'Quantity', dataField: 'quantity', width: 80, cellsalign: 'right' }, { text: 'Unit Price', dataField: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2' }, { text: 'Total', dataField: 'total', cellsalign: 'right', minwidth: 100, cellsformat: 'c2' } ] }); $("#jqxgrid2").jqxGrid( { width: 670, theme: theme, columnsresize: true, columns: [ { text: 'Name', dataField: 'firstname', width: 100 }, { text: 'Last Name', dataField: 'lastname', width: 100 }, { text: 'Product', editable: false, dataField: 'productname', width: 180 }, { text: 'Quantity', dataField: 'quantity', width: 80, cellsalign: 'right' }, { text: 'Unit Price', dataField: 'price', width: 90, cellsalign: 'right', cellsformat: 'c2' }, { text: 'Total', dataField: 'total', cellsalign: 'right', minwidth: 100, cellsformat: 'c2' } ] }); $("#jqxButton").on('click', function () { var rows = $('#jqxgrid').jqxGrid('getrows'); var source = { localdata: rows, datatype: "array", datafields: [ { name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' }, { name: 'total', type: 'number' } ] }; var dataAdapter2 = new $.jqx.dataAdapter(source); $("#jqxgrid2").jqxGrid({ source: dataAdapter2 }); }); }); </script></head><body class='default'> <div id='jqxWidget'> <div id="jqxgrid"> </div> <div id="jqxgrid2"> </div> <div> <input type="button" value="Copy" id='jqxButton' /> </div> </div></body></html>
In order to copy the whole data you can use the getrows method and than create a dataAdapter using the data returned by the getrows method.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHello sir,
first of all thanks for your reply.Please tell me how copy data from two jqxgrid into one jqxgrid in button clicking without selecting the rows in the jqxgrid.
Please give reply as soon as possible.Regards
priyanka jainHi priyankajain,
If you want to copy the data from two jqxGrid there is no need of selecting the rows. The approach is the same as the sample I sent you.
Best Wishes,
MariyajQWidgets Team
http://www.jqwidgets.comHello mam,
Thank u for your reply .I have try copy data from two jqxgrid into one jqxgrid but only one grid data copy.
Please send any sample and give reply as soon as possible.Regards
Priyanka jainHello sir,
please tell me how copy complete data of two jqxgrid into one jqxgrid on the clicking of button.you was send me sample but problem come when two grid data copy in one grid at a time on the button clicking..Please give me reply as soona s possible..Regards
priyanka jain -
AuthorPosts
You must be logged in to reply to this topic.