I have an Ultrawebgrid with two Divs in the RowEditTemplate, with a radiobutton list in each Div. One Div is displayed if any row but the last row is selected, the other is displayed only if the last row is selected. DivA has the radiobuttonlist only. DivB has a radiobuttonlist and a textbox. I have the javascript to determine which div opens. My problem is that no matter which Div is opened the radiobuttonlist always shows the selection of the last row. I've tried to write javascript function to initialize each control like I would an IG control, but visual studio expects their oninit methods to be in the code behind. These are standard ajax radiobuttonlists. How can I initialize them in javascript? Thanks.
This is a follow up. It seems it would be much easier to have one div. My Div has a table containing a row for the ID, row for the radiobuttonlist and a row for the text box. Instead of dealing with divs and multiple controls, the one div should suffice. What I cannot do in this instance is hide the row which has the text box. IN the BeforeRowTemplateOpenHandler, It should hide the row with the textbox for all rows selected except the last row, which will display both the radiobuttonlist and the textbox. I tried using igtbl_getElementById(templateId).children["divControls"].children["tblControls"].rows[2].style.display("none"); from a different example, but I get an error that the children tblcontrols doesn't exist.
Hello dbishop9,
If you want to initialize the combo box group from JavaScript events you can use window or body “onload” Client event - http://scriptasylum.com/tutorials/pageevents.html
This event is fired when the page or form is loaded and if the needed controls are available on the page you can access and modify them.
About your second question – your approach is correct (using “display = none” - http://www.javascriptf1.com/tutorial/javascript-hide-table-row.html?page=2 ) but in order to work correctly you will need to find the row HTML element first.
The correct element can be found by debugging your project or by using Developer tools (F12) to inspect and identify the needed element. Once the element is found you can use the mentioned code to hide it.
Let me know if you have additional questions.
Thanks Alex, this worked great. I have one issue left. (See image below). I have 5 rows with rbl controls. No matter which one I select, the rowedittemplate sets the rbl to the value of the last row in the table. In this example, value 3 shows Satisfied, however, when the template opens it shows Unsatisfied, which is the value of the last row. I have this set in the InitializeRow method as below, but it doesn't seeam to work. Any ideas, this is a standard asp radiobuttonlist control?
Dim rblValueA As RadioButtonList = igMyGrid.Bands(0).RowEditItem.FindControl("rblValueA")Try If Not IsNothing(rblValueA) Then rblValueA.SelectedIndex = e.Row.Cells(4).Text End IfCatch ex As ExceptionEnd Try
Hi Alex.
This example is for individual radiobutton controls. I am using a single radiobutton list with the text/value pairs as Satisfied=0, UnSatisfied=1, Not Used=2, Not Applicable=3. I've tried to adapt the example, but am so far unsuccessful. In the row I am testing, The value should be 3, but in the debugger the value always shows 0, but it doesn't even set the radiobuttonlist to 0, it still sets it to the value in the last row(which in this case is 1). Below is my code
function igMyGrid_TemplateUpdateControlsHandler(gridName, controlId, cellId, value) { if (controlId == "ctl00_ContentPlaceHolder1_igMyGrid_ctl00_rblValueA") { var cell = igtbl_getCellById(cellId); var lvalue = cell.getValue(); if (lvalue >= 0) { igtbl_getElementById(controlId).value = lvalue; } }}
If you are successfully accessing the embedded radio button list and setting the value properly (you can check this by debugging the code) for the needed item and the selection is still not correct you can set the selected value on Client-Side when template is opened.
This approach is shown in the following sample - http://help.infragistics.com/Help/NetAdvantage/ASPNET/2011.1/CLR4.0/html/WebGrid_Using_Row_Edit_Template.html
I hope that this approach will work in your scenario.