How to use batch edit for checkbox column in radgrid? - telerik

I've checkbox column in my Radgrid. I'm using Batch edit to edit the values. In the itemtemplate for the column, I need to display 'Yes'/'No' values based on the data from database which is 1 or 0 and when the cell is clicked, checkbox should be unchecked if the value is 'no' and viceversa.
When I'm clicking on the itemtemplate cell for edit, checkbox is coming as checked always in edititemtemplate(even if the value is No in itemtemplate), which is not expected.
<telerik:GridTemplateColumn HeaderText="Locked?" UniqueName="Locked" DataField="LockedInd" SortExpression="LockedInd">
<ItemTemplate>
<asp:Label ID="lblLocked" runat="server" Text='<%# Convert.ToBoolean(Eval("LockedInd")) ? "Yes" : "No" %>' />
</ItemTemplate>
<EditItemTemplate>
<asp:CheckBox runat="server" ID="chkLock" Checked='<%# Bind("LockedInd")%>'/>
</EditItemTemplate>
</telerik:GridTemplateColumn>

Per Telerik's documentation
When the EditMode is set to Batch, data binding expressions are not
allowed in the EditItemTemplate. RadGrid will (attempt to) set the editor's value
with JavaScript.
Telerik will try to automatically determine what the value of the control being edited should be, so a checked checkbox in the item template would reasonably translate to a checked check box in the edit template however a label does not intuitively convert to a checkbox.
The simplest solution without using other column types or controls would be to hook the clientSettings-ClientEvents-OnBatchEditOpened event and parse the value of the label to set the checkbox accordingly.
My assumption that may explain your always true behavior... because your data stored in a label is text/string based, when telerik attempts to assign the value of the label (using javascript as noted above), a non-null/non-empty string of "1" or "0" is truthy and results in a checked checkbox each time.

Related

How to get ID for onRowSelected event for asp.net webforms jqGrid?

I have implemented server side jqgrid with the following code
<trirand:JQGrid ID="jQGrid1" runat="server" OnDataRequesting="jQGrid1_DataRequesting" Height="220" LoadOnce="false" OnRowSelecting="jQGrid1_RowSelecting">
<AppearanceSettings ShowRowNumbers="true" />
<Columns>
<trirand:JQGridColumn DataField="AppId" HeaderText="Application ID" PrimaryKey="True" Width="100" />
<trirand:JQGridColumn DataField="Name" HeaderText="Application Name" Width="200"/>
<trirand:JQGridColumn DataField="Link" Width="280" />
</Columns>
<PagerSettings ScrollBarPaging="true" PageSize="20" NoRowsMessage="scroll down to fetch records" CurrentPage="1"/>
</trirand:JQGrid>
But for the onRowSelected Event when i check in my c# code i was getting selected index as some random values like jqg11,jqg25,....
why is it happening .What should i do to make one of my column to set as key when selected
I have checked below options
jQGrid1.SelectedRow
e.RowKey
I don't use commercial version of jqGrid, thus the code which you posted say me almost nothing. Nevertheless the reason of ids like jqg11 and jqg25 are typically errors in filling of the grid. jqGrid requires to assign id attribute to every row. So the server response should contains the id values. The exact information depends on the format of input data which you chosen, from the version of jqGrid which you use and from other options like id property of jsonReader or the existence of key: true property in one column of colModel. I recommend you to verify the JSON/XML data which you use to fill the grid. Probably you ddidn't specified correctly the id values.

How to get the value of a RadComboBox when it's in a RadGrid?

I'd like to be able to access the value of the item chosen from the radcombobox in the code behind. What can I write to access it when the user clicks insert?
(Please note that the comboboxes are dynamically generated so I cannot select a specific box)
<telerik:GridTemplateColumn UniqueName="UserCol" HeaderText="proto user" DataField="UserID">
<EditItemTemplate>
<telerik:RadComboBox ID="RadComboBox1" runat="server" AutoPostBack="false">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
update: what I mean to say by 'dynamically generated' is that the Radgrid has a button called "add new record". Everytime this button is clicked, a new radcombobox is generated. The user may generate any number of them at runtime.

How to set value in Ruby to text field with AutoPostBack on site in ASP

I have website written in ASP with searchTextBox with AutoPostBack and searchButton to search for value entered in searchTextBox.
Here is the code:
<asp:TextBox ID="searchTextBox" runat="server" AutoPostBack="True" Width="159px">enter value</asp:TextBox>
<asp:Button ID="searchButton" runat="server" Text="Search" Width="151px"
onclick="searchButton_Click" />
I would like to search for certain values using Ruby.
Here is my code:
search=#brows.text_field(:id=>'searchTextBox')
search.set(name)
#btnSearch=#brows.button(:id=>'searchButton')
#btnSearch.click
When I run script, value is entered, but before button is clicked it disapears.
How to stop this value disappearing?
When I do this manually value doesn't disappear. It is successfully send to next form.

Popupextender disappears after postback in Usercontrol

Dear Fellows i have a usercontrol which takes destination details from users with multiple dropdownlist controls...
e.g. Country Dropdownlist produces postback and populate states dropdownlist based on select values. State's Dropdownlist produces postback to get cities based on states.Furthermore everything happens in an Ajax UpdatePanel.
--Select--
I'm using this control in popupextender to be displayed. Each time dropdownlist postback popupcontrol disappears. Please help me with that
<asp:Panel ID="pnlhotelsearch" runat="server">
<div>
</div>
<uc1:SlimMainsearchpanel ID="SlimMainsearchpanel1" runat="server" />
</asp:Panel>
<ajaxToolkit:PopupControlExtender ID="PopupControlExtender1" TargetControlID="lnkbtnCriteriea" PopupControlID="pnlhotelsearch" runat="server">
</ajaxToolkit:PopupControlExtender>
There are several suggestions at ASP.net Modal Pop up extender and DropDownlist autopostback.
The way I solved it was to raise a new event, say DropDownChangedEvent, in the AutoPostBack event handler. The handler for the new DropDownChangedEvent calls PopupExtender.Show.

JSF Validation Error from Component that is not Rendered

I have a form that has a field that needs to be rendered as a read-only value when in edit mode and as a drop-down select list when in create mode.
The read-only field (used in edit mode) is rendered as plain text using <h:outputText>. In create mode, the field is rendered <h:selectOneListbox> that has a required attribute of "true".
It seems to work as I expect most of the time, but occasionally I get a validation error when in edit mode (the select list box is not rendered) .
Here is the code snippet that has both fields defined with their rendered attributes set using the same boolean value (just one field negates the boolean to toggle).
<h:outputLabel id="lblBusinessArea" value="Business Area:" />
<h:panelGroup id="baGroup">
<h:selectOneListbox id="businessAreaList" size="1"
rendered="#{shiftDetailsController.canEditBusinessArea}"
converter="businessAreaConverter"
value="#{shiftDetailsController.selectedBusinessArea}"
label="Business Area"
required="true">
<f:selectItems id="businessAreaListItems" value="#{shiftDetailsController.businessAreas}" />
<a4j:support id="businessAreaA4j" event="onchange"
ajaxSingle="true" reRender="deploymentGroupList, positionPayGroupList, sapPremCodeList" />
</h:selectOneListbox>
<h:outputText id="businessAreaRO"
rendered="#{!shiftDetailsController.canEditBusinessArea}"
value="#{shiftDetailsController.selectedBusinessArea.busAreaDesc}" />
</h:panelGroup>
Below is a screen clipping showing the field (in edit mode) rendered as read only. The "save" button was clicked and I get a validation error message that the field is required.
The value should be there in the backing bean because the value displayed is from the same object (shiftDetailsController.selectedBusinessArea). The output text uses the description field on the business area ojbect and the select field uses the whole object where the SelectItem has the description in the label.
Any idea how this could be occurring? I could set the required attribute using the same boolean value that determines the rendered state...so that it is only required when it is rendered...but since this problem is intermittent...I don't know that will really help.
I also verified that no other components on the page inadvertently have a label value of "Business Area" (which is being used in the validation message) to mislead me in which component truly has a null value; this is the only one that has the label of "Business Area".
I figured out what was happening with this issue.
Prior to submitting the form and receiving the validation error. I was making a change that caused the flag controlling the two components' visibility to be reversed.
rendered="#{shiftDetailsController.canEditBusinessArea}"
In other words, what I was doing on the form was causing the canEditBusinessArea to change values. But, I was not re-rendering the panel group ("baGroup") to cause the UI to reflect the update.
Thus, when my form was submitted the component during the validation phase was seen as being required...triggering the validation to happen. As soon as I added "baGroup" to the reRender of the action that was flipping the edit business area flag, the UI began reflecting the update and the submitted form had the value.

Resources