1

formate buttons(add,edit,delete,buttons not visible)

JqGrid Version : 4.4.4

following script is copied and then modified from : jqgrid EditActionIconsColumn Events

I need show add ,edit, delete buttons like in this demo :http://www.ok-soft-gmbh.com/jqGrid/ActionButtons.htm

<link href="~/Content/jquery.jqGrid/ui.jqgrid.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery.ui.button.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery.ui.theme.css" rel="stylesheet" />
<script src="~/Scripts/i18n/grid.locale-en.js"></script>
<script src="~/Scripts/jquery.jqGrid.min.js"></script>



$("#gridViewEditable").jqGrid({
            data: data,
            datatype: "local",
            cmTemplate: { sortable: false },
            colNames: ['Actions', "QuotationDetailID", "QuotationID", "ServiceID", "ServiceDescription", "Unit", "Rate", "Discount", "Frequency", "FrequencyBase", "Total"],
            colModel: [
                ///
                {
                    name: 'Actions', index: 'Actions', width: 55, align: 'center', sortable: false, formatter: 'actions',
                    formatoptions: {
                        keys: true, // we want use [Enter] key to save the row and [Esc] to cancel editing.
                        onEdit: function (rowid) {
                            alert("in onEdit: rowid=" + rowid + "\nWe don't need return anything");
                        },
                        onSuccess: function (jqXHR) {
                            // the function will be used as "succesfunc" parameter of editRow function
                            // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow)
                            alert("in onSuccess used only for remote editing:" +
                                  "\nresponseText=" + jqXHR.responseText +
                                  "\n\nWe can verify the server response and return false in case of" +
                                  " error response. return true confirm that the response is successful");
                            // we can verify the server response and interpret it do as an error
                            // in the case we should return false. In the case onError will be called
                            return true;
                        },
                        onError: function (rowid, jqXHR, textStatus) {
                            // the function will be used as "errorfunc" parameter of editRow function
                            // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#editrow)
                            // and saveRow function
                            // (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing#saverow)
                            alert("in onError used only for remote editing:" +
                                  "\nresponseText=" + jqXHR.responseText +
                                  "\nstatus=" + jqXHR.status +
                                  "\nstatusText" + jqXHR.statusText +
                                  "\n\nWe don't need return anything");
                        },
                        afterSave: function (rowid) {
                            alert("in afterSave (Submit): rowid=" + rowid + "\nWe don't need return anything");
                        },
                        afterRestore: function (rowid) {
                            alert("in afterRestore (Cancel): rowid=" + rowid + "\nWe don't need return anything");
                        },
                        delOptions: {
                            // because I use "local" data I don't want to send the changes to the server
                            // so I use "processing:true" setting and delete the row manually in onclickSubmit
                            onclickSubmit: function (rp_ge, rowid) {
                                // we can use onclickSubmit function as "onclick" on "Delete" button
                                alert("The row with rowid=" + rowid + " will be deleted");

                                // reset processing which could be modified
                                rp_ge.processing = true;

                                // delete row
                                grid.delRowData(rowid);
                                $("#delmod" + grid[0].id).hide();

                                if (grid[0].p.lastpage > 1) {
                                    // reload grid to make the row from the next page visable.
                                    // TODO: deleting the last row from the last page which number is higher as 1
                                    grid.trigger("reloadGrid", [{ page: grid[0].p.page }]);
                                }

                                return true;
                            },
                            processing: true // !!! the most important step for the "local" editing
                            //     skip ajax request to the server
                        }
                    }
                },
                ///
                { name: "QuotationDetailID", hidden: true },
                { name: "QuotationID", hidden: true },
                { name: "ServiceID", hidden: true },
                { name: "ServiceDescription", width: 150, editable: true },
                { name: "Unit", width: 75, editable: true },
                { name: "Rate", width: 75, editable: true },
                { name: "Discount", width: 75, editable: true },
                { name: "Frequency", width: 150, editable: true },
                { name: "FrequencyBase", width: 150, editable: true },
                { name: "Total", width: 150, editable: true },
            ],
            rowNum: 10,
            rowList: [5, 10, 20],
            pager: '#gridViewEditablePager',
            gridview: true,
            rownumbers: true,
            ignoreCase: true,
            //sortname: 'invdate',
            viewrecords: true,
            //sortorder: "desc",
            caption: "Quotation Services",
            height: "100%",
            editurl: 'clientArray',
            ondblClickRow: function (id, ri, ci) {
                // edit the row and save it on press "enter" key
                grid.jqGrid('editRow', id, true, null, null, 'clientArray');
            },
            onSelectRow: function (id) {
                if (id && id !== lastSel) {
                    // cancel editing of the previous selected row if it was in editing state.
                    // jqGrid hold intern savedRow array inside of jqGrid object,
                    // so it is safe to call restoreRow method with any id parameter
                    // if jqGrid not in editing state
                    if (typeof lastSel !== "undefined") {
                        grid.jqGrid('restoreRow', lastSel);
                    }
                    lastSel = id;
                }
            }
        }).jqGrid('navGrid', '#gridViewEditablePager', { add: false, edit: false }, {},{}, myDelOptions, { multipleSearch: true, overlay: false });

my JqGrid looks like this enter image description here

Community
  • 1
  • 1
Shamseer K
  • 4,964
  • 2
  • 25
  • 43
  • I'd recommend you don't use retro version 4.4.4. It's really very very old (published more as 3.5 years ago) and it's not supported since a long time. I'd recommend you to upgrade to [free jqGrid](https://github.com/free-jqgrid/jqGrid) 4.13.4. It's the for of jqGrid which I develop. It contains many enhancements, for example in `formatter: "actions"`. Try [the demo](http://www.ok-soft-gmbh.com/jqGrid/OK/CustomActionButton.htm) and [this one](http://www.ok-soft-gmbh.com/jqGrid/OK/CustomActionButton1.htm). See [the answer](http://stackoverflow.com/a/29735149/315935) for more details. – Oleg Sep 10 '16 at 11:32
  • @Oleg Thanks man,I was waiting for your answer,nice plugin, – Shamseer K Sep 10 '16 at 11:36
  • @Oleg I am planning to create tutorial on JqGrid with MVC in my blog – Shamseer K Sep 10 '16 at 11:39
  • You are welcome! I'd recommend you to use [Font Awesome](http://fontawesome.io/) buttons, which look better as jQuery UI icons (especially after scaling/zoom). See [here](http://free-jqgrid.github.io/getting-started/index.html#type_of_data) and [here](https://github.com/free-jqgrid/jqGrid/wiki/Using-Font-Awesome-in-free-jqGrid-4.8). One can use it directly from CDN (see [the wiki article](https://github.com/free-jqgrid/jqGrid/wiki/Access-free-jqGrid-from-different-CDNs)) or download from [NuGet](https://www.nuget.org/packages/free-jqGrid/) or [npm](https://www.npmjs.com/package/free-jqgrid). – Oleg Sep 10 '16 at 11:41
  • Thanks,I will update my source. – Shamseer K Sep 10 '16 at 11:45
  • @Oleg When I Updated with 4.13.4 ,column header and data column are shrinking- same source works fine with 4.4.4 – Shamseer K Sep 11 '16 at 06:54
  • I'm not sure that I understand correctly what you mean. If you have a problem, then you can get prepare the demo, which reproduces the problem. You can start with [this one](https://jsfiddle.net/OlegKi/5w5h2Lgw/11/) or [this one](https://jsfiddle.net/OlegKi/5w5h2Lgw/12/) and modify it to the demo, which has the problem, which you try to describe. – Oleg Sep 11 '16 at 10:08
  • @Oleg As I told you before I am working On jQGrid and Asp.Net MVC Integration Tutorial.Let me know the important topics like, Showing a List inside the table,Server Side Processing,Custom Search,Popup Crud Operation,Inline Editing etc, Can we chat ? – Shamseer K Aug 10 '17 at 04:17

1 Answers1

0

Got the solution - posting answer to my own question to help others

changed style sheet link

<link href="~/Content/themes/base/jquery.ui.theme.css" rel="stylesheet" />

with

<link rel="stylesheet" type="text/css" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/redmond/jquery-ui.css" />

It works fine now.

Shamseer K
  • 4,964
  • 2
  • 25
  • 43