jqGrid onselectrow - jqgrid

I'm using a jqGrid, and it gets populated fine. From the UI perspective, one of the columns in the jqGrid is editable. How can I make one of the columns as editable (say like a text box)?
The reason is, in my case when the grid successfully loads, the UI is going to show one of the column's values as editable.

If you're looking to edit the column values directly in the grid, similarly to how you might in Excel, look into the inline editing API:
http://www.trirand.com/jqgridwiki/doku.php?id=wiki:inline_editing&s[]=inline

In colmodel, you have to specify editable: true.Provide edit action link in editURL:... option of jqgrid.

you have to get the "id" of that column and then remove 'disabled' attribute on that.
for example -
$('#idofthatcolumn').removeAttr('disabled');
OR
$('#idofthatcolumn').removeAttr('readonly');

In your colmodel you should specify editable as true i.e, editable:true and specify the editUrl:'localhost:8080/yourApp'
Also if you want to store it in the client side, then specify it as editUrl:'clientArray'

Related

local form editing /adding using jqgrid 4.6.0 plugin

I have a jqgrid table in which I display my data,locally.
I need to add record,edit record and delete.I referred to Multiple jqGrid on one page, how to identify which grid on when click on "add" button on navigator? for jqgrid 4.5.4 version.
The add record doesn't work for me on jqgrid 4.6.0 version.It adds record succesfully only the first time.On subsequent attempts,The issue I am facing is,
onClickSubmit has postdata row values empty.So as result,it adds blank rows.
The code I use is exactly same as mentioned in the link above.The only change is my JSON data is :
data = [{'fname':'abc','lname':'def'},
{'fname':'efg','lname':'xyz'}]
Also,colNames and colModel looks like :
colNames:['fname','lname'],
colModel:[{'name:'fname', index:'fname', width:'40',editable: true,key:true},
{name:'lname', index:'lname', width:'60', sortable:false,editable: true}]
OnClickSubmit shows postdata with empty values for rows i.e. postdata.fname :' ',postdata.lname:' ',though I have added values in add record pop-up.Also,the add record dialog shows values in the text filled with previous values ,that were used when adding the record first time.Please help as I am really stuck up on this issue now!
Thanks,
Shweta
This issue was addressed in the jqGrid forum:
"The form edition[] does not support local editing. You can use inline edit for this purpose. See editurl option on how to point to local editing."
For inline editing, refer to jqGrid documentation.

Post non editable values in jqGrid?

I'm using jqGrid, and I would like to post non editable values to the server. I'm editing row by row (not form). Is that possible?
The column is visible, and I'm using inline editing. The data is posted using "editurl" property of the grid.
** Solution **
I solved it in a completely different way, by not using jqGrids setCell, but instead setting the textbox value using document.getElementById(selr + "_Verksamhetskod").value = data.
Not exactly what I had in mind initially, but it works...
Just add that to your cell configuration:
editable: true, editoptions: {disabled: true}
Well if I'm understanding correctly you are trying to make a cell become read-only once it has a value but still be in a format where you can post to the server correctly.
You could use Jquery to place a read-only attribute on each input field
$("#PrimaryKey".columnName").attr("disabled", true)
and either fire this code if there is a value in the input field or after an input has been entered.

jqgrid - dynamically load different colModel edittypes(Text box and check box) in two rows of same column

I'm doing some R&D work on displaying different colModel edittypes(Text box and check box) in two rows of the same column in a JqGrid. Because I need to display different edit-types for a same column depending on the back-end database values. Its possible to display different edit-types for different columns. Please help me on this to carry out my R&D work.
You don't explained which editing mode you use. The solution of the problem can be different depend on the editing mode.
I would you recommend to change the properties of the column, for example the edittype value, directly before the editing of the row be started.
In case of form editing you can change the properties inside of call . In the answer are shown how to show of hide some column property inside of beforeShowForm callback. Another answer or this one are examples of the usage beforeInitData which seems be the best for your case. Inside of beforeInitData you can change any properties of colModel before the form will be constructed.
Typical usage of inline editing consist from the calling of editRow inside of onSelectRow or inside of ondblClickRow. So one can use setColProp method for example to change column properties before there will be used. See examples here and here.

how to reorder columns in jqgrid by dragging column headers

jqgrid doc in here contains:
method allow to reorder the grid columns using the mouse. The only necessary setting in this case is to set the sortable option in jqGrid to true.
I have sortable: true but columns cannot reordered by dragging headers by mouse. How to re-order columns by dragging columns headers or other way without using column chooser ?
To implement sortable columns is really easy. You should just follow the documentation. You should just
include jquery-ui.min.js additionally to jquery-ui.css which are always required. The most people have the file already included because of usage jQuery UI Widgets like Datepicker, Autocomplete, Tabs and so on.
add sortable: true option to the grid.
Now you can already (see the demo) drag the column header and drop it on another position.

How do I edit a jqgrid from javascript

I have a jqgrid that has several columns including a checkbox column that indicates if an item is selected.
Underneath that I have a dropdown menu and a text box. The idea is that each item in the dropdown menu is a column in the jqgrid. Then all I need to do is modified all of the checked rows with the contents of the text box for that column. So a quick mass update mechanism if you will.
The problem is, is that I can't figure out how to update a specific cell. Any tips or documentation that can help me? Thanks!
You can use for example setRowData (see jqGrid documentation) or setCell to update the data in the grid. The functions getCol, getCell or getRowData could help you the examine the row data. Another old answers: this and this could be helpful if you decide to search data in the grid with respect of jQuery.
Here's the "answer" I came up with to my problem. I wanted to edit only rows that were editable. Using setCell would overwrite my editable field with a non-editable one. So I looked at the HTML for a given row while it is in the edit state and passed that into the 'setCell' method. It feels 'hackish' though and if someone knows a better way, I'm all ears.

Resources