Deprecated: iconv_set_encoding(): Use of iconv.internal_encoding is deprecated in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/string/string.php on line 28

Deprecated: iconv_set_encoding(): Use of iconv.input_encoding is deprecated in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/string/string.php on line 29

Deprecated: iconv_set_encoding(): Use of iconv.output_encoding is deprecated in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/string/string.php on line 30

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652
Edit Commands Buttons

Most Popular  


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652
   

Deprecated: Non-static method PhocaGalleryPath::getPath() should not be called statically, assuming $this from incompatible context in /home/datamerx/public_html2/codemerx/jqgrid/plugins/content/phocagallery/phocagallery.php on line 57

Deprecated: Non-static method PhocaGalleryPath::getInstance() should not be called statically, assuming $this from incompatible context in /home/datamerx/public_html2/codemerx/jqgrid/administrator/components/com_phocagallery/libraries/phocagallery/path/path.php on line 36

Deprecated: Non-static method PhocaGalleryLibrary::getLibrary() should not be called statically, assuming $this from incompatible context in /home/datamerx/public_html2/codemerx/jqgrid/plugins/content/phocagallery/phocagallery.php on line 64

Deprecated: Non-static method PhocaGalleryLibrary::getInstance() should not be called statically, assuming $this from incompatible context in /home/datamerx/public_html2/codemerx/jqgrid/administrator/components/com_phocagallery/libraries/phocagallery/library/library.php on line 44

Deprecated: Non-static method PhocaGalleryPath::getPath() should not be called statically, assuming $this from incompatible context in /home/datamerx/public_html2/codemerx/jqgrid/plugins/content/phocagalleryslideshow/phocagalleryslideshow.php on line 40

Deprecated: Non-static method PhocaGalleryPath::getInstance() should not be called statically, assuming $this from incompatible context in /home/datamerx/public_html2/codemerx/jqgrid/administrator/components/com_phocagallery/libraries/phocagallery/path/path.php on line 36

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652

Edit Commands Buttons

This is a really simplified demo of how one could add visible editing functionality to jqGrid (have in mind that jqGrid has the built-in navGrid feature that provides similar functionlity).

What we do here is we add a new column to jqGrid that never gets any data. Instead we use a custom formatter to dynamically generate buttons in that column that could perform the basic edit commands.

You can find the code below. The custom formatter that generates the buttons is the displayButtons function.

        $(document).ready(function () {
            'use strict';
             var gidData = [
                    {action:"", id: "1", orderdate: "2013-10-01", customer: "customer",  price: "200.00", vat: "10.00", completed: true, shipment: "TN", total: "210.00"},
                    {action:"", id: "2", orderdate: "2013-10-01", customer: "customer2",  price: "300.00", vat: "20.00", completed: false, shipment: "FE", total: "320.00"},
                    {action:"", id: "3", orderdate: "2011-07-30", customer: "customer3",  price: "400.00", vat: "30.00", completed: false, shipment: "FE", total: "430.00"},
                    {action:"", id: "4", orderdate: "2013-10-04", customer: "customer4",  price: "200.00", vat: "10.00", completed: true, shipment: "TN", total: "210.00"},
                    {action:"", id: "5", orderdate: "2013-11-31", customer: "customer5",  price: "300.00", vat: "20.00", completed: false, shipment: "FE", total: "320.00"},
                    {action:"", id: "6", orderdate: "2013-09-06", customer: "customer6",  price: "400.00", vat: "30.00", completed: false, shipment: "FE", total: "430.00"},
                    {action:"", id: "7", orderdate: "2011-08-30", customer: "customer7",  price: "200.00", vat: "10.00", completed: true, shipment: "TN", total: "210.00"},
                    {action:"", id: "8", orderdate: "2013-10-03", customer: "customer8",  price: "300.00", vat: "20.00", completed: false, shipment: "FE", total: "320.00"},
                    {action:"", id: "9", orderdate: "2013-09-01", customer: "customer9",  price: "400.00", vat: "30.00", completed: false, shipment: "TN", total: "430.00"},
                    {action:"", id: "10", orderdate: "2013-09-08", customer: "customer10", price: "702.00", vat: "30.00", completed: true, shipment: "IN", total: "530.00"},
                    {action:"", id: "11", orderdate: "2013-09-08", customer: "customer11",  price: "500.00", vat: "30.00", completed: false, shipment: "FE", total: "530.00"},
                    {action:"", id: "12", orderdate: "2013-09-10", customer: "customer12",  price: "500.00", vat: "30.00", completed: false, shipment: "FE", total: "530.00"}
                ],
                theGrid = $("#theGrid"),
                numberTemplate = {formatter: 'number', align: 'right', sorttype: 'number'}

        
            theGrid.jqGrid({
                datatype: 'local',
                data: gidData,
                colNames: ['Action','Customer', 'Date',  'Price', 'VAT', 'Total', 'Completed', 'Shipment'],
                colModel: [
                	  {name:'action',index:'action',sortable:false, formatter: displayButtons},
				    	  {name: 'customer', index: 'customer', width: 90, editable:true},
                    {name: 'orderdate', index: 'orderdate', width: 100, align: 'center', sorttype: 'date',
                        formatter: 'date', formatoptions: {newformat: 'd-M-Y'}, datefmt: 'd-M-Y'},
                    {name: 'price', index: 'price', width: 55, template: numberTemplate},
                    {name: 'vat', index: 'vat', width: 42, template: numberTemplate},
                    {name: 'total', index: 'total', width: 50, template: numberTemplate},
                    {name: 'completed', index: 'completed', width: 30, align: 'center', formatter: 'checkbox',
                        edittype: 'checkbox', editoptions: {value: 'Yes:No', defaultValue: 'Yes'}},
                    {name: 'shipment', index: 'shipment', width: 80, align: 'center', formatter: 'select',
                       edittype: 'select', editoptions: {value: 'FE:FedEx;TN:TNT;IN:Intime;us:USPS', defaultValue: 'Intime'}}                  
                ],
				gridview: true,             
				rownumbers: false,
                rowNum: 10,
                rowList: [5, 10, 15],
                pager: '#gridPager',
                viewrecords: true,	
                caption: 'Edit Commands Buttons',
                height: '100%'
            });
        });
        
        function displayButtons(cellvalue, options, rowObject)
			{
    			var edit = "<input style='...' type='button' value='Edit' onclick=\"jQuery('#theGrid').editRow('" + options.rowId + "');\"  />", 
					 save = "<input style='...' type='button' value='Save' onclick=\"jQuery('#theGrid').saveRow('" + options.rowId + "');\"  />", 
					 restore = "<input style='...' type='button' value='Restore' onclick=\"jQuery('#theGrid').restoreRow('" + options.rowId + "');\" />";
				return edit+save+restore;
			}

 


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652
Posted: 2 years 11 months ago by chandu #509

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652
chandu's Avatar
By using above code it is saving locally, I need to edit and save in sql database. Please help.

Thanks,
Chandu

   

Social Login  


 
   

Your Cart  


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652
The cart is empty
   

Latest Forum Posts  


Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652

  • Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/datamerx/public_html2/codemerx/jqgrid/libraries/joomla/filter/input.php on line 652