Using jqGrid (4.4) with Grails (2.0.3).
I have a grid with checkbox columns. Data is local and not using Grails editUrl property to submit data. I'm submitting the entire page to the backend controller using a regular submit button.
Here's the rub ...
Say the grid contains 5 rows and the 5 checkboxes (indexes 0-4) have values of (true, false, true, true, false). What gets to the controller via the params map is an array of 3 checkbox values, all true with indexes 0, 1, 2. So, only the 'true' values are passed to the controller, but I have no idea which row they belong to.
Please advise. Thanks in advance.
Not specific to grails, this is just a common html/webdevelopment question.
Unchecked checkboxes aren't sent to the server when form is submitted.
And you dont have to keep the submitted value of a checkbox to true, you can use any custom value (the value attribute) and then on server you can identify which checkboxes where checked based on the values
See this thread as well
Related
I am trying to display multiple dropdowns on post back on razor page in my ASP.NET MVC application inside a for loop using Dictionary<CountryCode, <selectList item with Country Selected>>.
Unfortunately, the selected value is lost and the dropdown is displayed with default selection.
enter image description here
Soultion found: The MVC Postback method required cleaning of ModalState as well. The Dynamically removed dropdowns were cleaned from our viewModel alone, cleaning it from the ModalState as well, solved the issue.
Because: Dropdownlistfor in the back end has a field called attempted value that was causing the dropdown selected value to get wiped out.
Thanks
I want to populate values in a list box based on a value entered in textbox. It cant be aceived through cascading paramters as all parameters in Cascading parameters are List Boxes. But my requirement is to populate values inside a ListBox based on the value entered inside a textbox. Please help.
Cascading parameter is the only way to define a dependency between two parameters. As you can see, the birt web viewer displays a textbox just below each combobox, and a radio button to select if we fill each list parameter from the combobox or the textbox:
I know some users had exactly the same requirement, and have successfully modified "ComboBoxParametersFragments.jsp" to display only the textbox when it is needed. For example we can use a specific prefix in the parameter name, or a user property, so that we can decide in the JSP if we hide the combobox or not.
I have a JQGrid with a hidden column, I would like the data in this column to be posted back to the server when the user edits it in the edit dialog box.
As it stands, the only way I can see this form data in the postback is when using the column property Editable = true, however, this then displays a text input box on the dialog. With Editable = false the input box is hidden but the value is not in the postback.
Having the property displayed in the edit dialog is not ideal as I don't want the user to be able to change the value, but I need it posted back to the server for business logic reasons.
Any help would be appreciated.
You can hide the data in client side by $('#tr_<ColumnName>').hide();
Use it in appropriate places like in ADD and EDIT functions of the JqGrid.
I solved the problem through this way. Any elegant suggestion is welcome.
P.S - Actually credit goes to my team-mates. They found the way.
We know that in MVC, a CheckBoxFor will generate a checkbox with a value="true" and a hidden with a value=false. Both input controls will share the same name.
It is very reasonable because the form will be able to POST a false value if the box is unchecked. And the model binder will ignore the hidden input when the checkbox return a true.
But now i have overridden the form submit event in order to send the form data into a WebAPI controller in JSON format.
When serializing the form data, there is no mechanism to parse the relationship between the checkbox and the hidden correctly. Therefore, when unchecked, it returns a false, which is okay. But when checked, it returns a {true, false} instead of true, because the serializeArray() function goes through every input and find two values goes to a same name.
The question is: What is the best way to correct it?
My solution to this problem was to write my own HtmlHelper method that renders a single <input type="checkbox" /> tag. Any other solution just seemed too hacky.
You can use dotPeek or .NET Reflector to look at how the Microsoft Team created the HtmlHelper.CheckboxFor method if you need any help accomplishing that task.
The 2 tag approach was taken to prevent MVC action parameters from throwing an exception when a "bool" parameter did not have a matching parameter sent to the controller (an unchecked checkbox doesn't send any value).
I am using Entity Framework Database First approach in ASP.NET MVC.
I have created models from an existing database and everything works fine.
I am using jqGrid and trying to create a drop down list for a column which is defined as an Int in the database.
In the database, the values are either 0 or 1, so in the dropdown list I will have to show two values such as "Import" or "Export" based on whether it is 0 or 1.
Would I be able to handle this scenario in the jqGrid?
Please post any suggestions if you have!
I think you can handle this thing in colModal itself. there's is one option editOption you can specify with you colModal and based on the value you are getting from data you can specfy the text property of that column
In this case, the data for the grid should contain “One” or “Two” to be set in the column myname.
Now, with this setting
<script>
jQuery("#grid_id").jqGrid({
...
colModel : [ {name:'myname', edittype:'select', formatter:'select', editoptions:{value:"1:One;2:Two"}} ... ]
...
});
</script>
the data should contain the keys (“1” or “2”), but the value (“One”, or “Two”) will be displayed in the grid.
check this link for further help. You will get your answer. Because you didn't post your code(atleast you should have done that for ur that particular column) i can not say you are implementing the same way.