jqgrid, setting value of an editable select control - drop-down-menu

I have an editable grid, with one of its column is a SELECT type, e.g.
colModel:[{ name:'myText',index:'myTextColumn',editable: true, edittype: 'text'},
{name:'myList',index:'myList', width:editable: true,edittype: "select",
editoptions: { value: {'v1':'Value 1','v2':'Value 2',....} },
............
]
I use the method setRowData to set data in one of the rows by code. The value that I pass for the Select type cell is the option value, e.g.
jQuery("#myGrid").setRowData( rowId, { myText:"Text 2", myList:"v2", ..... })
After executing this code, the text type cell displays "Text 2", as expected. However, the the Select type cell displays "v2" not "Value 2". Only when I click that cell the display changes to "Value 2"
How can I force the select type cell display the correct value without the need for manual click later?

Meanwhile I found the solution for this problem. Just add a formatter of type "select" to the column.
http://www.secondpersonplural.ca/jqgriddocs/_2kn0mlo1p.htm

Related

Iterate through each element in a particular column of a dynamic table using cypress

I have a dynamic table displayed based on a value selected from a radio button in my project. The radio button field "Doctor Name" field has different choices like "Frank", "Michael", "Josh", "Jessica". When I select the "Frank" value, it displays a dynamic table with the list of appointments for "Frank", The first column in the table is "Doctor Name". When I select "Frank" from the radio button, I have to validate if all the appointments listed are for "Frank". So I have to write coding in cypress to check if all the first column cell values are "Frank".
How can I achieve this?
retrieve all the first columns using cy.get() with the proper selector, then use the each command to validate the content of each cell, something like this
cy.get("selector for first colums").each(($el, index, $list) => {
cy.wrap($el).contains('Frank')
})

Microsoft Word 2013 - form field - based on dropdown value show / hide fields

I've got several fields in my document . Based on a dropdown-field I want to show / hide several other fields.
Told in another way. I have a dropdown that have these options "Custom", "As sunday", "Closed". If the dropdown value is "custom" then I should show the field "time". All the other options it should just print the dropdown value.
In my word file, it's like this
[dropdown] [time]
Ex: dropdown value is "custom", the field should be like below (only showing time):
0800 - 1600
Ex: dropdown value is "closed", the field should be like below (only showing the dropdown value):
closed
I've tried to use a formula like this:
{ IF "{dropdown}" = "custom", "", {dropdown} }
I think the problem is that "dropdown" field are changing when a user picks a value from the dropdown. is there a way to insert the value from the dropdown.. like REF "{dropdown}"
If you still don't understand what I'm trying to get.. told in the third way:
if the dropdown shows "Custom" I only want to display the time when the store is open.
if the dropdown shows anything else but custom it should just print the value of the dropdown, and leave the time "blank"
Assuming that you are using legacy form fields, only trying to change what is displayed, not what fields the user gets to enter (it's ambiguous as far as #"time" is concerned) then you need something like this:
{ IF "{ dropdownfieldname }" = "custom" "{ TIME }" "{ dropdownfieldname }" }
where
- all the {} are the special field code brace pairs that you can insert using ctrl-F9 on Windows Word
- dropdownfieldname is the name of the drop down field (set in its properties). It is possible to relocate this bookmark name in which case you will need to rename the dropdown a couple of times at develeopment time to re-impose it
- "custom" must be "custom" as written in the dropdown's list of values. i.e. if it's "Custom", use "Custom". Or use
{ IF "{ dropdownfieldname \*upper }" = "CUSTOM" "{ TIME }" "{ dropdownfieldname }" }
{ TIME } is the built-in time field. If you really want a reference to another form field value, that happens to have bookmark "time", you will probably need "{ ref time }" instead. If your field is actually called "timefield", use "{ timefield }"
If you are using Content controls, IMO the best way to do it is actually to create a custom XML part, link the dropdown result to an element in the part, link a plain text content control to the same element, and literally insert that control where I have put { dropdownfieldname }. Ditto for { timefieldm }

How to bind null value to jqgrid that contains all rows in Editable format

I am using jqgrid in my asp.net application. I am making all the grid rows in editable fomat in the LoadComplete trigger of the jqgrid as follows:
ids = $("#grid").jqGrid('getDataIDs');
var l = ids.length;
for (var i = 0; i <= l; i++) {
$("#grid").jqGrid('editRow', ids[i], true);
}
In two of the columns , i have dropdown lists . Here, the based on the external dropdown change, some rows get addded to the jqgrid.
When added, they contain the Null values initially.
So, inorder to show null values in grid. I am adding an list item , to display them.
The problem is here , i should not allow users to again select null values.
So, i need that option in the dropdown list only once that is before a selection is made.
later, it should not be visible or selectable..
Please help on this..
Updated:
Initially the grid contains no rows..
On the dropdown change , the grid gets refreshed and new rows are added based on dropdown selection.
grid data
for example:
col1 col2 col3 col4
Item1 Null null null
Item2 Null Null Null
similarly like this:
Here, Col1 is not editable rest of them are editable.
Col2 and Col4 are dropdowns
I am loading select options into dropdown by using
editoptions: {
value: { " ": " ", "option1": "option1", "option2": "option2", "option2": "option2", "option3": "option3" },
Here, my problem is that .. the user should not be able to select that null option .
I have included it for the intial data binding.
IF i am not including that null option("")
then the dropdowns are showing with option 1 as default but the user has not yet selected any option.
I am not sure that I understand correct your problem. If you just need to remove null or "" entry from drop-down you can do this by using dataInit (the property of editoptions). The corresponding code could be about the following
dataInit: function (elem) {
$(elem).find("option[value=\"\"]").remove();
}
Probably other implementation could be better for you. For example you can unselect any option if the current selected option is "". See the answer for details. In any way I think that you should use dataInit to makes some corrections.

jqGrid - Disable Reordering of Specific Columns

I have a jqGrid with the grid-level 'sortable' option enabled. This lets me drag columns around to reorder them, which is great. But I want to prevent users from doing this with one specific column, leaving the others unaffected. Is this possible?
I find your question very interesting and so I made the corresponding demo which demonstrate the solution. On the demo is the first column "Date" unsortable.
I recommend you to read two other old answers on the close subject: this and this. My suggesting are based on the same idea.
There are internal jqGrid method sortableColumns which will be used internally if one uses sortable: true option of jqGrid. The sortableColumns method uses jQuery Sortable for the implementation and initializes items options of the grid having id="list" to the value ">th:not(:has(#jqgh_list_cb,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)". It makes the columns "cb", "rn" and "subgrid" unsortable. The columns could be inserted in the grid if you use jqGrid options multiselect: true, rownumbers: true or subGrid: true. In the same way is you have the column with name: "invdate" then the corresponding id of the column element will be jqgh_list_invdate. So one can use the option sortable as the following
sortable: {
options: {
items: ">th:not(:has(#jqgh_list_cb,#jqgh_list_invdate,#jqgh_list_rn,#jqgh_list_subgrid),:hidden)"
}
}
to make the "invdate" column unsortable.

Clear jqgrid toolbar when custom defaultvalue is set

I want to clear the toolbar of my grid, but not to the default value of the column. I want to empty all fields.
When I use the
$("#Jqgrid")[0].clearToolbar();
method the toolbar gets the initial default values..
You can choose one from the following two ways.
1) You can temporary change the defaultValue of the searchoptions to "" before call of clearToolbar. You can use setColProp method for example to change column properties (see en example here).
2) Set the value of the the toolbar element manually to "" or to any other value which you want. There are simple way how the ids of the input or select elements of the toolbar are constructed. Let us you have column with the name 'col1' (the corresponding column of colModel has name: 'col1'). Then the id of the element in the filter toolbar will be gs_col1. So you can use
$("#gs_col1").val("");
to clear the field. In more general case if the colname is the variable which hold the value from colModel[i].name you can use
$("#gs_" + $.jgrid.jqID(colname)).val("");

Resources