how can i get inbuilt value during Add process of jqgrid? - jqgrid

I am using jqGrid and when I want to enter new values,I click on Add(+) button which is at bottom of grid.I have 7 filed and out of them 1 is dropdown list so,
whenever I want to add new record I want that dropdown field to be filled automatically. How do I achieve that ?

I'm not sure what you exactly mean. Du you use inline editing (inlineNav) or form editing (navGrid)? Which version of jqGrid you use and from which fork of jqGrid (free jqGrid, which I develop, commercial Guriddo jqGrid JS or an old jqGrid in version <=4.7). You wrote about "dropdown field to be filled automatically", but the information can be interpreted in different ways. I try to guess.
I suppose that you should include defaultValue in editoptions to fill (or to choose in the dropdown) the default value in the filed new filed. It will work in case of usage form editing. It could work in some cases of usage inline editing (inlineNav) too, but one should know more details about your implementation.

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.

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.

jQgrid multiselect with dynamic changed cell value based on dropdown selection

I just found that sample
http://www.ok-soft-gmbh.com/jqGrid/DataToMultiSelect2.htm
I want to have something similar:
I want to be able to post selected values on server and also i want to have a dropdown and based on that dropdown selection another cell value of that row gettign changed
How can i do that?
|Id|Dropdown|ValueChangedOnDropdownChanged|
1 A[A/B] A selected
2 B[A/B] B selected
*[A/B] it is dropdown options
I am not sure that I understand your question correct. The demo which you reference in your question I created before for the answer and this one.
Look at the another old demo. It shows how to implement dependent select (dropdown) list. The demo shows how to it in inline editing, form editing and the searching toolbar. In case of the usage of server base data you will have to use dataUrl and buildSelect to implementation of the same behavior. The dataUrl should be used instead of the v property of the searchoptions or editoptions. The buildSelect can be used ton only to modify the server response, but just as the good place to rebuild the dependent select (dropdown list).

jqGrid form edit stuck with initially loaded values

When I open form to edit values:
It doesn't change form values when I navigate with <> buttons
It opens New form with same values as first edited row, and when I click "Submit", it overwrites that row instead of creating a new item
When I click to edit another row, it always shows the form values for the first edited row – i.e. if I click New first and then edit row, it shows empty form.
So, in short, the first time form opens, the values are "stuck" whatever row I open later.
What can cause this? I remember it used to work OK some time ago.
UPDATE:
No with recreateForm I don't have this issue (I use it as temporary workaround).
Hm, I can reproduce this on jqGrid example, but not on Live Manipulation - on New in Version 3.7, Add/edit/delete on local data:
Click any row and edit it (open form)
Close form
Select any other row and click edit - form shows incorrect values (from the row that was opened first)
Click Add new row button in toolbar - form shows same values - which is very convenient, usually new rows are "almost" same - if only it would add new row, not update the existing one!
Of course in live demo Submit doesn't do that (it doesn't seem to work at all) but except for this symptoms are same.
Also <> buttons do not change data in form, though they change selected row - but from what I remember previously it used to update form values also to match selected row.
Probably you should post the description of your bug with "New in Version 3.7", "Add/edit/delete" as a bug in the in trirand forum.
The problem is that the bug exist in very special environment/data/settings. For example I tested my old local edit example modified to jqGrid 3.8.1 or in 3.7.2 and can not reproduce the problem which you describes. So you can use my examples as a template could it helps you.
Moreover in all examples which I use for real projects I use always parameter recreateForm:true. If you don't use it jqGrid not create a form, but try to use an existing with other data. It works in a lot of cases wrong. For example if you use any dataInit functions they will be called only once during creating of the form, which can make very strange affects. If you use edittype: 'custom' the usage of recreateForm:true is really mandatory (see this). So I recommended many times all people to use
jQuery.extend(jQuery.jgrid.edit, {recreateForm: true});
to set recreateForm: true as your default settings. You could save many hours or days of debugging of some strange effects in your edit/add dialogs.

jqGrid using radio buttons for editable rows

I'm currently using jqGrid and ASP.Net MVC. With my current project, my goal is to provide a grid of data to the end user, and they can then edit this. The data is machine-generated, and the users will be confirming if the machine is correct or not.
I think ideally for speed, I'd like to provide a row per item, with a radio button group as the editable. The users could then pick from the values 'Unknown', 'Correct', 'Incorrect'.
As there will be a lot of data, I'd also like to provide a control of some type that can set all rows in the grid to one of the available radio button choices, for the user experience.
Given that there seems to be no native support for this in jqGrid, I wanted to ask if anyone has had any experience writing something like this, and whether this is achievable and reliable, or whether I should stick with the drop-down editable approach that is native to jqGrid.
To implement radio button as the editable instead of the standard drop-down editable approach you can use so named custom editing feature of jqGrid (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:common_rules#custom). This allows you to create any custom control to edit the cell value. An example of the implementation you can find here: Add multiple input elements in a custom edit type field.
To set all rows in the grid to one of the available radio button choices you can use either a control outside of jqGrid or add an additional custom button in the navigation bar (see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons). If you search for navButtonAdd you will find a lot of examples how to implement this, for example, Jqgrid: navigation based on the selected row. Because you use server based data, you can just call a method on the server to make the changes which you need and then call trigger("reloadGrid") to refresh jqGrid data.

Resources