3

i have a jqgrid in my application, which is working fine but its slight different from my requirement, when in click on a particular cell, the whole row is getting selected but i want only that particular cell to be selected...the next one is im able to update the row values on hitting the 'Enter' key, but i want the cell value to be updated as soon as the user leaves that particular cell

this is my jquery code

<script type="text/javascript">
    $(function () {
        var lastsel;

        jQuery("#list").jqGrid({
            url: '/Home/GetStudents/',
            datatype: 'json',

            mtype: 'POST',
            colNames: ['StudentID', 'FirstName', 'LastName', 'Email'],
            colModel: [
      { name: 'StudentID', sortable: false, key: true },
      { name: 'FirstName', key: true },
      { name: 'LastName', sortable: false, key: true },
      { name: 'Email', width: 200, sortable: false, key: true}],
            cmTemplate: { align: 'center', editable: true },
            pager: '#pager',
            width: 750,
            rowNum: 15,
            rowList: [5, 10, 20, 50],
            sortname: 'StudentID',
            sortorder: "asc",
            viewrecords: true,
            caption: ' My First JQgrid',
            onSelectRow: function (StudentID) {


                if (StudentID != lastsel) {


                    jQuery('#list').jqGrid('restoreRow', lastsel);
                    jQuery('#list').jqGrid('editRow', StudentID, true);

                    lastsel = StudentID;

                }

            },

            editurl: '/Home/About/',

            caption: "jQgrid Sample"

        });

        jQuery("#list").jqGrid('navGrid', "#pager", { edit: false, add: false, del: false });
    });

</script>
colors bright
  • 107
  • 1
  • 3
  • 18

1 Answers1

2

It seems that you use wrong editing mode. jqGrid supports tree editing modes which can be additionally used in many variations.

The description of your requirements looks that you should use cell editing instead of inline editing which you use currently.

Oleg
  • 220,925
  • 34
  • 403
  • 798
  • so with this grid , any of my requirements are not possible, i.e editing only the cell on which the suer clicks and updating the value when the user leaves the cell? – colors bright Dec 03 '12 at 09:00
  • @colorsbright: I need to remind you that you get the product with full source code for *free*. Additionally you can find a lot of examples which shows how to use it. Do you believe that somebody will implement your exact requirements also for free? jqGrid save cells during keyboard navigation. If you need to save it on `focusout` or on `blur` you can bind your event handler with respect of `dataEvents` properties of [editoptions](http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules#editoptions) and call `saveCell` explicitly. – Oleg Dec 03 '12 at 09:15
  • @colorsbright: I am not sure what you mean. You can use the most controls which you need. One have to write very small or more long JavaScript code to include the controls in jqGrid. For example you can easy use the most jQuery UI controls like datepicker, autocomplete and so on. [The demo](http://www.ok-soft-gmbh.com/jqGrid/ranking1_441.htm) see [the answer](http://stackoverflow.com/a/12744780/315935) and [another](http://www.ok-soft-gmbh.com/jqGrid/simplelocalgridwithsearchingtoolbarmultilpe1.htm) from [another answer](http://stackoverflow.com/a/12875703/315935) shows usage of custom control – Oleg Dec 03 '12 at 10:40