DefaultModelBinder and binding action parameters from values in a table row - asp.net-mvc-3

What I am doing is this. I have a basic table with a button at the end of each row for "selection" of that row for further actions. My action method has two simple parameters I'll call them id1 and id2 so:
public ActionResult DoSomething(int id1, int id2)
id1 will be bound from a hidden form field outside the scope of the table, this works fine.
id2 needs to come from a hidden column from an individual row in the table depending on the button clicked representing the row that requires further processing. Make sense?
When the form posts back to the action method, id1 is set perfectly, no problem, but id2 is always the value of the hidden column from row 1. How do I detect/make DefaultModelBinder pull the hidden column value from the row from which the button is being clicked?
Thanks for the assist as I am actively trying to figure this out.
Here is the hidden table column that is rendered per row that I want to capture it's value on the post from the row from which the button was clicked:
<td style="display:none;">#Html.Hidden("id2", viewModel.id2)</td>

You could use simple hyper links instead of forms on each row. Like this:
#Html.ActionLink("link text", "DoSomething", "SomeController", new {
id1 = viewModel.id1, id2 = viewModel.id2
}, null)
which assuming default routes should generate the following link:
/somecontroller/DoSomething?id1=123&id2=456
and when you click on it the DoSomething action will be invoked with correct parameters.
If you want to do this with POST you will need multiple forms, one for each row:
#using (Html.BeginForm("DoSomething", "somecontroller"))
{
#Html.Hidden("id1", viewModel.id1)
#Html.Hidden("id2", viewModel.id2)
<input type="submit" value="OK" />
}

Related

KendoUI Grid column not re-rendering when data changes

I have a KendoUI grid with a column named "Status" :
Problem
Upon changing the value of a cell, I trigger the saving and update the grid with new data. The rows are updating but the status column is not re-rendering.
More details about the issue
The 1st row is the filter and the remainings are the actual rows.
Filter applied => Where status = Paid.
I've modified row 3 to set the status to "Not Paid".
I've triggered the Save to the backend database, then fetch all the rows where Status = Paid and then re-assign the new data to the kendo-grid.
Expected result
We have one less row in the table because the status of row 3 has changed.
All the rows in the table have "Paid" status.
Obtained result
One less row in the table. => Good
The row 4 before is now Row 3. => Good
The status of Row 3 (ex row 4) is still "Not Paid" even though in the data obtained it is "Paid". => Error
Additional notes
The html code for the column is below.
On cell value edit, the changes are saved in a dictionary on client side. When the client clicks on the save button, all changes are sent to the backend.
Assigning the new data to the kendo-grid
The table is bound to this variable which gets updated when there're new data.
<kendo-grid
[data]="this.dataAggregative.data"
...>
...
</kendo-grid>
The template for the column
<kendo-grid-column
[editable]="true"
field="status"
title="Status">
<ng-template kendoGridFilterCellTemplate let-filter>
<drop-down-list-filter
class="k-filtercell-wrapper"
[filter]="filter"
[data]="statusFilterEntries"
textField="text"
valueField="status">
</drop-down-list-filter>
</ng-template>
<ng-template kendoGridCellTemplate let-dataItem>
<div class="toolbar-container container">
<kendo-dropdownlist
[data]="statusFilterEntries"
textField="text"
valueField="status"
(selectionChange)="statusSelectionChange($event, dataItem.id)"
[value]="statusFilterEntries[dataItem.status == statusEnum.NotPaid ? 0 : 1]">
</kendo-dropdownlist>
</div>
</ng-template>
</kendo-grid-column>
Issue fixed by updating the model locally before pushing all the changes to the backend.

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')
})

Oracle Apex 4.2 Tabular Form checkbox for changed column value

I have an Apex Tabular form:
ID Name Title Class ROW_EDIT <br>
1 Smith Mgr AP (checkbox)<br>
etc...
I am trying to activate the 'checkbox' ROW_EDIT column - which has a default value of Y - when the user changes the value for the tabular form column Class (Select list) in the same row. I can change the ROW_EDIT attribute to text (ie, Y) if easier...
I have no apex_items for the page to reference - all columns are tabular form.
I have researched some dynamic change events - but I can't seem to get the row-reference to set correctly.
Any help would be greatly appreciated.
Thanks
Unfortunately, last time I saw APEX 4.2 was 2 years ago and I don't have it now.
The idea is in the following:
Add onchange event to select list. I don't remember is there an easy way to do this. If not, you can create a select list manually using APEX_ITEM package. To do this, write in the source query:
select apex_item.select_list_from_lov (
p_idx => 10,
p_value => class, -- it is a name of a table column
p_lov => 'my_lov_name',
p_attributes => 'onchange="my_func.call(this);"')
from ...
In page properites (JavaScript section), create a javascript function:
function my_func () {
this.parentElement.parentElement.getElementsByTagName("input")[0].checked = true;
}
Parameter this in the function is a reference to select list. Hence, this.parentElement.parentElement - reference to row with the triggering select list, getElementsByTagName("input")[0] is a checkbox. If you have several input elements in the row, use proper index instead of 0.
How this JavaScript code works you can check here: https://codepen.io/anon/pen/NvPmPp

making my tabular form dynamic

I have a checkbox on a tabular form. I need to be able to hide it if the submit date is not filled in and show it when a date is there. Once the checkbox has been clicked, I need to update another field based on the checkbox being clicked or when I hit the update button. is this possible on a Oracle Apex tabular form in version 4.2?
You can create dynamic actions on tabular form fields, but you need to know some Javascript / jQuery / DOM stuff as it can't be done declaratively as it can with page items.
As an example, I created a simple tabular form on the EMP table:
Using the browser's Inspect Element tool I can see that the HTML for the Ename field on row 3 looks like this:
<input type="text" name="f03" size="12" maxlength="2000" value="Ben Dev"
class="u-TF-item u-TF-item--text " id="f03_0003" autocomplete="off">
The relevant bits to note are the name "f03" and the ID "f03_0003". For all tabular form fields, the name indicates the column, and is the same for all fields in that column. The ID is made up of the name plus a string to represent the row - in this case "_0003" to represent row 3.
Similarly, the Hiredate fields are all named "f004" and have IDs like "f04_0003".
Armed with this information we can write a dynamic action. For example, let's say that whenever Ename is empty then Hiredate should be hidden, otherwise shown. In pseudo-code:
whenever an element with name "f03" is changed, the element with name "f04" on the same row should be hidden or shown.
So we can create a synamic action with a When condition like this:
Event = Change
Selection type = jQuery selector
jQuery selector = input[name="f03"]
i.e. whenever an input whose name is "f03" is changed, fire this action.
The action performed will have to be "Execute Javascript code", and the code could be:
// Get the ID of this item e.g. f03_0004
var this_id = $(this.triggeringElement).attr('id');
// Derive the ID of the corresponding Hiredate item e.g. f04_0004
var that_id = 'f04'+this_id.substr(3);
if ($(this.triggeringElement).val() == "") {
// Ename is empty so hide Hiredate
$('#'+that_id).closest('span').hide();
} else {
// Ename is not empty so show Hiredate
$('#'+that_id).closest('span').show();
}
Because Hiredate is a date picker, I needed to hide/show both the field itself and its date picker icon. I chose to do this by hiding/showing the span that contains them both. This code could have been written in many different ways.
You could apply similar techniques to achieve your aims, but as you can see it isn't trivially easy.

Counting a field value response weekly basis in Lotus Notes

I have radio button field in a form whose value can be 1 or 2 or 3. I have a made a view out of this form and there one column will contain the value of this radio button field . Whenever a customer submits the form, a new document will appear in the view. A customer can submit the form many times with different value of this radio button. Is it possible to know how many times a particular customer selected the value 1?
Yes, you can create a view where the first column is your customer name and the second column is their response. Both columns should be "categorized" meaning they'll group the like values.
For each column you can set the formula to include the number of documents within the group. For example:
CustomerName + " (" + #DocChildren + ")"
will show you "ABC Company (12)" if ABC had 12 responses.

Resources