Hacer clic en editar en una fila no genera una devolución de datos

I downloaded this jqgrid sample from: http://tpeczek.codeplex.com/releases/view/61796

I updated the 'basics' grid and an editbutton shows up on each row. I would like to go to another Editpage when clicking this and passing in the productID. However there is no postback? Also how can I make the productID display the right value because right now it shows the productname (ev is shifted to the left)

cuadrícula

<script type="text/javascript">
        $(document).ready(function () {
            $('#jqgProducts').jqGrid({
                //url from wich data should be requested
                url: '@Url.Action("Products")',
                //type of data
                datatype: 'json',
                //url access method type
                mtype: 'POST',
                //columns names
                colNames: ['Actions', 'ProductID', 'ProductName', 'SupplierID', 'CategoryID', 'QuantityPerUnit', 'UnitPrice', 'UnitsInStock'],
                //columns model
                colModel: [
                     { name: 'act', index: 'act', width: 55, align: 'center', sortable: false, formatter: 'actions' },
                     { name: 'ProductID', index: 'ProductID', align: 'left' },
                            { name: 'ProductName', index: 'ProductName', align: 'left' },
                            { name: 'SupplierID', index: 'SupplierID', align: 'left' },
                            { name: 'CategoryID', index: 'CategoryID', align: 'left' },
                            { name: 'QuantityPerUnit', index: 'QuantityPerUnit', align: 'left' },
                            { name: 'UnitPrice', index: 'UnitPrice', align: 'left' },
                            { name: 'UnitsInStock', index: 'UnitsInStock', align: 'left' }
                          ],
                //pager for grid
                pager: $('#jqgpProducts'),
                //number of rows per page
                rowNum: 10,
                //initial sorting column
                sortname: 'ProductID',
                //initial sorting direction
                sortorder: 'asc',
                //we want to display total records count
                viewrecords: true,
                //grid height
                height: '100%',
                editurl: '/Edit'
            });

            $('#jqgProducts').navGrid('#pagerComponents', { edit: false }).
         navButtonAdd('#pagerComponents', {
             caption: "fdsfsdf",
             title: "Edit Component",
             buttonicon: "ui-icon-pencil",
             onClickButton: function () {
                 var id = jQuery("#listComponents").getGridParam('selrow');
                 if (id) {
                     var data = jQuery("#listComponents").getRowData(id);
                     window.location = '/Edit/' + data.COMPONENTID;
                 }
                 else {
                     alert("Please select a row to edit.");
                 }
             }
         });





        });


    </script>

preguntado el 31 de julio de 12 a las 14:07

1 Respuestas

so for the first part in your question, if you want to redirect to a particular url on the click of edit button in that row then you will need to specify a couple of things with action formatter. I tell you how

http://www.ok-soft-gmbh.com/jqGrid/ActionButtons41WithoutMultiedit.htm

check this example here, we are giving deloptions with action formatter and you can specify url for edit like this

editOptions:{url: '@Url.Action("EditAction")', restoreAfterError: false}

and the rows which are editable their data will go to server by default, you need to specify editable:true with columns you want editable like this for example

{ name: 'ProductName', index: 'ProductName', align: 'left', editable:true },

so now if you click on edit of action formatter it will take you to the "EditAction" with editable column data and you can use it there.

For the second part, it all looks fine to me. can you check the data you are getting from server which you are loading to jqgrid has same name alphabetically as your column names here in jqgrid, else check the response in fiddler or developer tools.

Respondido 31 Jul 12, 16:07

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.