Hi all,
http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html
foreach(GridItem item in RadGrid1.MasterTableView.Items)
{
if (item is GridEditableItem)
{
GridEditableItem editableItem= item as GridDataItem;
editableItem.Edit = true;
}
}
RadGrid1.Rebind();
i am using the method in the above link to make my Radgrid editable on click of a button.
But.. this is not working... in fact when i click on another button t change it back to normal mode...it now appears in edit mode.!!!
can anyone help me?
Thanks in advance
John
http://www.telerik.com/help/aspnet/grid/grddefaulteditmodeforgriditemsoninitialload.html
foreach(GridItem item in RadGrid1.MasterTableView.Items)
{
if (item is GridEditableItem)
{
GridEditableItem editableItem= item as GridDataItem;
editableItem.Edit = true;
}
}
RadGrid1.Rebind();
i am using the method in the above link to make my Radgrid editable on click of a button.
But.. this is not working... in fact when i click on another button t change it back to normal mode...it now appears in edit mode.!!!
can anyone help me?
Thanks in advance
John
20 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 09 Sep 2008, 03:55 AM
Hello John,
Try out the following code, to make the entire grid editable on a button click.
cs:
Princy.
Try out the following code, to make the entire grid editable on a button click.
cs:
protected void Button1_Click(object sender, EventArgs e) |
{ |
foreach (GridDataItem item in RadGrid1.MasterTableView.Items) |
{ |
item.Edit = true; |
} |
RadGrid1.Rebind(); |
} |
Princy.
0
Dorababu
Top achievements
Rank 1
answered on 25 Aug 2012, 12:22 PM
Hi princy this didn't work for me....
0
Princy
Top achievements
Rank 2
answered on 27 Aug 2012, 09:47 AM
Hi Dorababu,
I guess you want to make the entire RadGrid in edit mode on a button click. Try setting AllowMultiRowEdit property of RadGrid to true.
ASPX:
Thanks,
Princy.
I guess you want to make the entire RadGrid in edit mode on a button click. Try setting AllowMultiRowEdit property of RadGrid to true.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowMultiRowEdit
=
"true"
>
Thanks,
Princy.
0
Dorababu
Top achievements
Rank 1
answered on 27 Aug 2012, 11:09 AM
I would like to edit the selected radgrid row to edit mode on external button click as per you suggest I write your code in my radwindowmanager on button click but didn't work
Also I set as per you suggested still the same issue
protected
void
rdbtnYes_Click(
object
sender, EventArgs e)
{
foreach
(GridDataItem item
in
RadGrid2.MasterTableView.Items)
{
item.Edit =
true
;
}
//RadGrid2.MasterTableView.InsertItem();
//foreach (GridDataItem item in RadGrid2.MasterTableView.Items)
//{
// item.Edit = true;
//}
RadGrid2.Rebind();
rdwmdw1.Windows[0].VisibleOnPageLoad =
false
;
}
Also I set as per you suggested still the same issue
0
Dorababu
Top achievements
Rank 1
answered on 27 Aug 2012, 01:12 PM
Hi princy what I find is in Item Data bound I make my edit to false when the status is No as follows
When coming to rawindow manager when I clicked on Yes and set to True as per you said it is not working. But if in Item Databound If is e.Item,Edit=true, this is working fine. But as per my requirement I would like to preview the edit when user clicks Yes from radwindow.
protected
void
RadGrid2_ItemDataBound(
object
sender, GridItemEventArgs e)
{
int
iPagecount = RadGrid2.MasterTableView.CurrentPageIndex;
if
(e.Item
is
GridDataItem)
{
if
(iPagecount == 0)
{
if
(e.Item.ItemIndex != 0)
{
GridDataItem item = (GridDataItem)e.Item;
ImageButton imageButton = (ImageButton)item[
"imgEdit"
].Controls[0];
imageButton.Visible =
false
;
//imageButton.ImageUrl = "images/MailOk.png";
}
else
{
GridDataItem item = (GridDataItem)e.Item;
ImageButton imageButton = (ImageButton)item[
"imgEdit"
].Controls[0];
imageButton.Visible =
true
;
}
}
else
{
GridDataItem item = (GridDataItem)e.Item;
ImageButton imageButton = (ImageButton)item[
"imgEdit"
].Controls[0];
imageButton.Visible =
false
;
}
}
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
mlocal_strStoredProcName = StoredProcNames.Gender_uspGenderGetList;
oEmployeePersonalData.Select(
out
mlocal_ds, mlocal_strStoredProcName);
Label lblStatus = (Label)item.FindControl(
"lblApprovalStatus1"
);
if
(lblStatus.Text ==
"Y"
)
{
if
(!e.Item.OwnerTableView.IsItemInserted)
{
Label LBL1 = (Label)item.FindControl(
"lblMaritalStatus"
);
RadComboBox rdcmbGender = (RadComboBox)item.FindControl(
"rdcbGender"
);
rdcmbGender.DataSource = mlocal_ds;
rdcmbGender.DataTextField = TablesAndColumns.tblGender_GenderDesc;
rdcmbGender.DataValueField = TablesAndColumns.tblGender_GenderTypeID;
rdcmbGender.SelectedValue = (
string
)DataBinder.Eval(e.Item.DataItem,
"MaritalTypeID"
).ToString();
//rdcmbGender.SelectedValue = LBL1.Text;
rdcmbGender.DataBind();
mlocal_strStoredProcName = USADAO.StoredProcNames.PayFrequency_uspPayFrequencySelect;
oEmployee.FedTaxID = Session[
"FedTaxID"
].ToString();
oEmployee.Select(
out
mlocal_ds, mlocal_strStoredProcName);
RadComboBox ddlPayFrequencytype = (RadComboBox)item.FindControl(
"rdcbPayFrequency"
);
ddlPayFrequencytype.DataSource = mlocal_ds;
ddlPayFrequencytype.DataTextField =
"PayFrequencyDesc"
;
ddlPayFrequencytype.DataValueField =
"PayFrequencyType"
;
ddlPayFrequencytype.DataBind();
ddlPayFrequencytype.Enabled =
false
;
mlocal_ds.Clear();
RadDatePicker radDtStartDate = item.FindControl(
"radDtStartDate"
)
as
RadDatePicker;
RadDatePicker radDtEndDate = item.FindControl(
"radDtEndDate"
)
as
RadDatePicker;
strDate = radDtStartDate.SelectedDate.Value;
EndDt = radDtEndDate.SelectedDate.Value;
}
}
else
{
e.Item.Edit =
false
; // Set to false
RadWindowManager2.RadConfirm(
"Approve item "
+
""
+
"?"
,
"confirmCallBackFn"
, 300, 100,
null
,
"My Confirm"
);
//rdwmdw1.Windows[0].VisibleOnPageLoad = true;
}
}
}
When coming to rawindow manager when I clicked on Yes and set to True as per you said it is not working. But if in Item Databound If is e.Item,Edit=true, this is working fine. But as per my requirement I would like to preview the edit when user clicks Yes from radwindow.
0
KARTHIK
Top achievements
Rank 1
answered on 04 Apr 2014, 11:44 AM
Hi,
I have an issue to find edit form controls after radconfirm "OK" click will fire radgrid_onupdate command via javascript.
below is the scenario,
Click on edit form update button i have radconfirm based on some
condition,once click "OK" in radconfirm will fire
radgrid_onupdatecommand event via javascript.next time i will skip the
radconfirm and update
below is the code
Aspx code
<telerik:RadGrid ID="RadGrid2" runat="server" Skin="Office2007" GridLines="None" AllowMultiRowEdit="true"
Visible="true" OnPreRender="RadGrid2_PreRender" AllowFilteringByColumn="false "
AllowPaging="True" PageSize="20" AllowSorting="True" Width="100%" AutoGenerateColumns="False"
OnNeedDataSource="RadGrid2_NeedDataSource" OnInsertCommand="RadGrid2_InsertCommand"
ShowStatusBar="true" AllowAutomaticUpdates="False" OnUpdateCommand="RadGrid2_OnUpdateCommand"
HorizontalAlign="NotSet" OnItemDataBound="RadGrid2_ItemDataBound" OnItemCommand="RadGrid2_ItemCommand">
<MasterTableView CommandItemDisplay="Top" DataKeyNames="oid,oidTradeMaster" ClientDataKeyNames="oidTradeMaster"
EditMode="PopUp">
<CommandItemTemplate>
<table width="100%">
<tr>
<td width="15%">
<asp:LinkButton ID="btnadd"
runat="server" CommandName="InitInsert" Visible='<%#
!RadGrid1.MasterTableView.IsItemInserted %>'><img
style="border:0px;vertical-align:middle;" alt=""
src="Icons/AddRecord.png"/> Add New
Record</asp:LinkButton>
</td>
<td width="55%">
<asp:LinkButton ID="btnbreaktrade"
OnClientClick="ShowBreakTrade();" runat="server"><image id="img1"
style="border:0px;vertical-align:middle;" alt=""
src="Icons/AddRecord.png"/> Break
Trade</asp:LinkButton>
</td>
<td width="30%" align="right">
<asp:LinkButton ID="btnrefresh"
runat="server" CommandName="RebindGrid"><img
style="border:0px;vertical-align:middle;" alt=""
src="Icons/Refresh.png"/> Refresh</asp:LinkButton>
</td>
</tr>
</table>
</CommandItemTemplate>
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditColumn">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn UniqueName="oid" HeaderText="oid" DataField="oid" DataType="System.Int32"
Visible="false" />
<telerik:GridBoundColumn UniqueName="StartDate" HeaderText="Start Date" DataFormatString="{0:MM/dd/yy}"
AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
Visible="true" DataField="StartDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="EndDate" HeaderText="End Date" DataFormatString="{0:MM/dd/yy}"
AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
Visible="true" DataField="EndDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Units" HeaderText="Units" DataField="Units"
FilterControlWidth="30px" AllowFiltering="true" AutoPostBackOnFilter="true" Visible="true"
CurrentFilterFunction="Contains">
<ItemStyle Width="30px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="SwapPrice" HeaderText="Swap Price" FilterControlWidth="50px"
AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
DataField="SwapPrice">
<ItemStyle Width="50px" />
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete"
ConfirmText="Are you sure want to delete the selected Entry?" ConfirmDialogType="Classic"
ConfirmTitle="Delete" ButtonType="ImageButton" ImageUrl="~/Icons/delete.png" />
</Columns>
<EditFormSettings InsertCaption="Add New Trade Detail" CaptionFormatString="Edit Trade Entry "
EditFormType="Template" PopUpSettings-Modal="false" PopUpSettings-Width="650"
PopUpSettings-Height="240">
<FormTemplate>
<asp:Panel runat="server" ID="pnldetails">
<table id="Table1" cellspacing="1" cellpadding="1" width="650" border="0">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbltradetype" runat="server" Text="Trade Type"></asp:Label>
</td>
<td>
<asp:CheckBox ID="chkDailyVolumes" runat="server" Checked="false" Visible="true"
AutoPostBack="true" Text="Use Daily Volumes" OnCheckedChanged="Check_Clicked"
ToolTip="Load Trade with Daily Volumes" />
<telerik:RadComboBox
ID="RcbTradeType1" EmptyMessage="Select Tradetype" runat="server"
Width="110px"
AutoPostBack="true" Visible="false"
OnSelectedIndexChanged="RcbTradeType_SelectedIndexChanged">
<Items>
<telerik:RadComboBoxItem Text="EOM" Value="EOM" />
<telerik:RadComboBoxItem Text="DOM" Value="DOM" />
</Items>
</telerik:RadComboBox>
<telerik:RadNumericTextBox
ID="RNtxtTradeday" Visible="false" Width="90px" runat="server"
NumberFormat-DecimalDigits="0" EmptyMessage="Enter Trade day">
</telerik:RadNumericTextBox>
</td>
</tr>
<tr>
<td>
Start Date:
</td>
<td colspan="3">
<%-- <telerik:RadDateInput
ID="RDIStartDate" runat="server" Width="200px" AutoPostBack="false">
<ClientEvents OnValueChanging="MyValueChanging" />
</telerik:RadDateInput>--%>
<telerik:RadDatePicker
ID="RDIStartDate" runat="server" Width="200px" AutoPostBack="false"
Calendar-FastNavigationStep="12" DateInput-EmptyMessage="" MinDate="01/01/1000"
MaxDate="01/01/3000">
</telerik:RadDatePicker>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator9" runat="server"
ControlToValidate="RDIStartDate"
Display="Dynamic"
ErrorMessage="</br>* StartDate is Required." ValidationGroup="VAL"
/>
</td>
<td>
End Date:
</td>
<td colspan="3">
<%--<telerik:RadDateInput ID="RDIEndDate" runat="server" Width="200px">
<ClientEvents OnValueChanging="MyValueChanging" />
</telerik:RadDateInput>--%>
<telerik:RadDatePicker
ID="RDIEndDate" runat="server" Width="200px" AutoPostBack="false"
Calendar-FastNavigationStep="12" DateInput-EmptyMessage="" MinDate="01/01/1000"
MaxDate="01/01/3000">
</telerik:RadDatePicker>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator10" runat="server"
ControlToValidate="RDIEndDate"
Display="Dynamic"
ErrorMessage="</br>*EndDate is Required." ValidationGroup="VAL"
/>
</td>
</tr>
<tr>
<td>
Units:
</td>
<td colspan="3">
<telerik:RadComboBox
runat="server" ID="RcbUnits" EnableLoadOnDemand="True"
OnItemsRequested="RcbUnits_ItemsRequested"
AutoPostBack="false" EnableVirtualScrolling="true" ShowMoreResultsBox="true"
MarkFirstMatch="true" HighlightTemplatedItems="true" Height="60px" Width="200px"
DropDownWidth="200px">
</telerik:RadComboBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator11" runat="server"
ControlToValidate="RcbUnits"
Display="Dynamic"
ErrorMessage="</br>*Units is Required." ValidationGroup="VAL"
/>
</td>
<td>
<asp:Label
ID="lblperiodvolume" runat="server" Text="Period
Volume"></asp:Label>
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtPeriodVolume" Width="200px" runat="server"
NumberFormat-DecimalDigits="2"
Text='<%# Bind( "PeriodVolume") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator12" runat="server"
ControlToValidate="txtPeriodVolume"
Display="Dynamic"
ErrorMessage="</br>*PeriodVolume is Required."
ValidationGroup="VAL" />
</td>
</tr>
<tr>
<td>
Swap Price:
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtSwapPrice" Width="200px" runat="server"
NumberFormat-DecimalDigits="6"
Text='<%# Bind( "SwapPrice") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator
ID="rqfSwapPrice" runat="server" ControlToValidate="txtSwapPrice"
Enabled="false" Display="Dynamic" ErrorMessage="</br>*SwapPrice is Required."
ValidationGroup="VAL" />
</td>
<td>
Floor:
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtFloor" Width="200px" runat="server"
NumberFormat-DecimalDigits="6"
Text='<%# Bind( "Floor") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator ID="rqfFloor" runat="server" ControlToValidate="txtFloor"
Enabled="false"
Display="Dynamic" ErrorMessage="</br>*Floor is Required."
ValidationGroup="VAL" />
</td>
</tr>
<tr>
<td>
Ceiling:
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtCeiling" Width="200px" runat="server"
NumberFormat-DecimalDigits="6"
Text='<%# Bind( "Ceiling") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator
ID="rqfCeiling" runat="server" ControlToValidate="txtCeiling"
Enabled="false"
Display="Dynamic" ErrorMessage="</br>*Ceiling is Required."
ValidationGroup="VAL" />
</td>
<td>
Trade ID:
</td>
<td colspan="3">
<asp:TextBox
ID="txttradeiddetail" Text='<%# Bind( "TradeID") %>'
runat="server"
Width="200px">
</asp:TextBox>
</td>
</tr>
<tr runat="server" id="Tdetails">
<td>
Termination Date:
</td>
<td colspan="3">
<telerik:RadDatePicker ID="RDITerminationdatedetail" runat="server" Width="200px"
AutoPostBack="false" Calendar-FastNavigationStep="12" DateInput-EmptyMessage=""
MinDate="01/01/1000" MaxDate="01/01/3000">
</telerik:RadDatePicker>
</td>
<td>
Terminated Volume:
</td>
<td colspan="3">
<telerik:RadTextBox
ID="txtTvoldetail" Width="200px" runat="server" Text='<%# Bind(
"breakvol") %>'>
</telerik:RadTextBox>
</td>
</tr>
<tr runat="server" id="Tdetails1">
<td>
New ExternalID:
</td>
<td colspan="3">
<telerik:RadTextBox
ID="txtnewextiddetail" Width="200px" runat="server" Text='<%# Bind(
"newbreakid") %>'>
</telerik:RadTextBox>
</td>
</tr>
</table>
</asp:Panel>
<table style="width: 100%">
<tr>
<td align="center" colspan="2">
<asp:Button ID="Button3"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update"
%>'
OnClientClick="disable_button(this)" ValidationGroup="VAL"
runat="server" CommandName='<%# (Container is GridEditFormInsertItem)
? "PerformInsert" : "Update" %>'>
</asp:Button>
<asp:Button ID="Button4"
Text="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel">
</asp:Button>
</td>
<td>
<asp:Label ID="lblerror"
Font-Size="Small" Font-Bold="true" ForeColor="Red" runat="server"
Text=""></asp:Label>
</td>
<div style="display: none">
<asp:Button ID="Button1"
Text="Finish" runat="server" Visible="true" OnClick="Button3_Click">
</asp:Button>
</div>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
<GroupingSettings CaseSensitive="false" />
</telerik:RadGrid>
javascript that fires update commnd event
function confirmCallBackFn1(arg) {
}
if (arg == true) {
document.getElementById('hdnconfirm').value = "1";
var masterTable = $find("<%= RadGrid2.ClientID %>").get_masterTableView();
masterTable.fireCommand("update", "0");
}
}
Updatecommand event with radconfirm--when i clcik on radconfirm "OK" below event is firing but not able find the edit form controls.
protected void RadGrid2_OnUpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
var insertedItem = e.Item as GridEditFormItem;
if (insertedItem == null)
{
GridDataItem insertedItem1 = (GridDataItem)e.Item;
insertedItem = insertedItem1.EditFormItem;
//e.Item.Edit = true;
//insertedItem.Edit = true;
//GridItem item = (GridItem)RadGrid2.MasterTableView.Items[0]; // Get the first item
//item.Edit = true; // Set in EditMode
//RadGrid2.MasterTableView.Rebind();
for (int i = 0; i < RadGrid1.PageSize; i++)
{
RadGrid2.EditIndexes.Add(i);
}
//foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
//{
// item.Edit = true;
//}
//RadGrid2.Rebind();
}
DateTime Tdate = Convert.ToDateTime(insertedItem["BreakDate"].Text);
RadDatePicker RDIstart = (RadDatePicker)insertedItem.FindControl("RDIStartDate");
if (RDITerminationdatedetail.SelectedDate != Tdate && hdnconfirm.Value == "0")
{
RadWindowManager1.RadConfirm("alert msg", "confirmCallBackFn1", 330, 180, null, "Terminate trade");
return;
}
//update code will follow
}
I have an issue to find edit form controls after radconfirm "OK" click will fire radgrid_onupdate command via javascript.
below is the scenario,
Click on edit form update button i have radconfirm based on some
condition,once click "OK" in radconfirm will fire
radgrid_onupdatecommand event via javascript.next time i will skip the
radconfirm and update
below is the code
Aspx code
<telerik:RadGrid ID="RadGrid2" runat="server" Skin="Office2007" GridLines="None" AllowMultiRowEdit="true"
Visible="true" OnPreRender="RadGrid2_PreRender" AllowFilteringByColumn="false "
AllowPaging="True" PageSize="20" AllowSorting="True" Width="100%" AutoGenerateColumns="False"
OnNeedDataSource="RadGrid2_NeedDataSource" OnInsertCommand="RadGrid2_InsertCommand"
ShowStatusBar="true" AllowAutomaticUpdates="False" OnUpdateCommand="RadGrid2_OnUpdateCommand"
HorizontalAlign="NotSet" OnItemDataBound="RadGrid2_ItemDataBound" OnItemCommand="RadGrid2_ItemCommand">
<MasterTableView CommandItemDisplay="Top" DataKeyNames="oid,oidTradeMaster" ClientDataKeyNames="oidTradeMaster"
EditMode="PopUp">
<CommandItemTemplate>
<table width="100%">
<tr>
<td width="15%">
<asp:LinkButton ID="btnadd"
runat="server" CommandName="InitInsert" Visible='<%#
!RadGrid1.MasterTableView.IsItemInserted %>'><img
style="border:0px;vertical-align:middle;" alt=""
src="Icons/AddRecord.png"/> Add New
Record</asp:LinkButton>
</td>
<td width="55%">
<asp:LinkButton ID="btnbreaktrade"
OnClientClick="ShowBreakTrade();" runat="server"><image id="img1"
style="border:0px;vertical-align:middle;" alt=""
src="Icons/AddRecord.png"/> Break
Trade</asp:LinkButton>
</td>
<td width="30%" align="right">
<asp:LinkButton ID="btnrefresh"
runat="server" CommandName="RebindGrid"><img
style="border:0px;vertical-align:middle;" alt=""
src="Icons/Refresh.png"/> Refresh</asp:LinkButton>
</td>
</tr>
</table>
</CommandItemTemplate>
<Columns>
<telerik:GridEditCommandColumn UniqueName="EditColumn">
</telerik:GridEditCommandColumn>
<telerik:GridBoundColumn UniqueName="oid" HeaderText="oid" DataField="oid" DataType="System.Int32"
Visible="false" />
<telerik:GridBoundColumn UniqueName="StartDate" HeaderText="Start Date" DataFormatString="{0:MM/dd/yy}"
AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
Visible="true" DataField="StartDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="EndDate" HeaderText="End Date" DataFormatString="{0:MM/dd/yy}"
AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
Visible="true" DataField="EndDate">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="Units" HeaderText="Units" DataField="Units"
FilterControlWidth="30px" AllowFiltering="true" AutoPostBackOnFilter="true" Visible="true"
CurrentFilterFunction="Contains">
<ItemStyle Width="30px" />
</telerik:GridBoundColumn>
<telerik:GridBoundColumn UniqueName="SwapPrice" HeaderText="Swap Price" FilterControlWidth="50px"
AllowFiltering="true" AutoPostBackOnFilter="true" CurrentFilterFunction="EqualTo"
DataField="SwapPrice">
<ItemStyle Width="50px" />
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName="Delete" Text="Delete" UniqueName="Delete"
ConfirmText="Are you sure want to delete the selected Entry?" ConfirmDialogType="Classic"
ConfirmTitle="Delete" ButtonType="ImageButton" ImageUrl="~/Icons/delete.png" />
</Columns>
<EditFormSettings InsertCaption="Add New Trade Detail" CaptionFormatString="Edit Trade Entry "
EditFormType="Template" PopUpSettings-Modal="false" PopUpSettings-Width="650"
PopUpSettings-Height="240">
<FormTemplate>
<asp:Panel runat="server" ID="pnldetails">
<table id="Table1" cellspacing="1" cellpadding="1" width="650" border="0">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lbltradetype" runat="server" Text="Trade Type"></asp:Label>
</td>
<td>
<asp:CheckBox ID="chkDailyVolumes" runat="server" Checked="false" Visible="true"
AutoPostBack="true" Text="Use Daily Volumes" OnCheckedChanged="Check_Clicked"
ToolTip="Load Trade with Daily Volumes" />
<telerik:RadComboBox
ID="RcbTradeType1" EmptyMessage="Select Tradetype" runat="server"
Width="110px"
AutoPostBack="true" Visible="false"
OnSelectedIndexChanged="RcbTradeType_SelectedIndexChanged">
<Items>
<telerik:RadComboBoxItem Text="EOM" Value="EOM" />
<telerik:RadComboBoxItem Text="DOM" Value="DOM" />
</Items>
</telerik:RadComboBox>
<telerik:RadNumericTextBox
ID="RNtxtTradeday" Visible="false" Width="90px" runat="server"
NumberFormat-DecimalDigits="0" EmptyMessage="Enter Trade day">
</telerik:RadNumericTextBox>
</td>
</tr>
<tr>
<td>
Start Date:
</td>
<td colspan="3">
<%-- <telerik:RadDateInput
ID="RDIStartDate" runat="server" Width="200px" AutoPostBack="false">
<ClientEvents OnValueChanging="MyValueChanging" />
</telerik:RadDateInput>--%>
<telerik:RadDatePicker
ID="RDIStartDate" runat="server" Width="200px" AutoPostBack="false"
Calendar-FastNavigationStep="12" DateInput-EmptyMessage="" MinDate="01/01/1000"
MaxDate="01/01/3000">
</telerik:RadDatePicker>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator9" runat="server"
ControlToValidate="RDIStartDate"
Display="Dynamic"
ErrorMessage="</br>* StartDate is Required." ValidationGroup="VAL"
/>
</td>
<td>
End Date:
</td>
<td colspan="3">
<%--<telerik:RadDateInput ID="RDIEndDate" runat="server" Width="200px">
<ClientEvents OnValueChanging="MyValueChanging" />
</telerik:RadDateInput>--%>
<telerik:RadDatePicker
ID="RDIEndDate" runat="server" Width="200px" AutoPostBack="false"
Calendar-FastNavigationStep="12" DateInput-EmptyMessage="" MinDate="01/01/1000"
MaxDate="01/01/3000">
</telerik:RadDatePicker>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator10" runat="server"
ControlToValidate="RDIEndDate"
Display="Dynamic"
ErrorMessage="</br>*EndDate is Required." ValidationGroup="VAL"
/>
</td>
</tr>
<tr>
<td>
Units:
</td>
<td colspan="3">
<telerik:RadComboBox
runat="server" ID="RcbUnits" EnableLoadOnDemand="True"
OnItemsRequested="RcbUnits_ItemsRequested"
AutoPostBack="false" EnableVirtualScrolling="true" ShowMoreResultsBox="true"
MarkFirstMatch="true" HighlightTemplatedItems="true" Height="60px" Width="200px"
DropDownWidth="200px">
</telerik:RadComboBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator11" runat="server"
ControlToValidate="RcbUnits"
Display="Dynamic"
ErrorMessage="</br>*Units is Required." ValidationGroup="VAL"
/>
</td>
<td>
<asp:Label
ID="lblperiodvolume" runat="server" Text="Period
Volume"></asp:Label>
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtPeriodVolume" Width="200px" runat="server"
NumberFormat-DecimalDigits="2"
Text='<%# Bind( "PeriodVolume") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator
ID="RequiredFieldValidator12" runat="server"
ControlToValidate="txtPeriodVolume"
Display="Dynamic"
ErrorMessage="</br>*PeriodVolume is Required."
ValidationGroup="VAL" />
</td>
</tr>
<tr>
<td>
Swap Price:
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtSwapPrice" Width="200px" runat="server"
NumberFormat-DecimalDigits="6"
Text='<%# Bind( "SwapPrice") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator
ID="rqfSwapPrice" runat="server" ControlToValidate="txtSwapPrice"
Enabled="false" Display="Dynamic" ErrorMessage="</br>*SwapPrice is Required."
ValidationGroup="VAL" />
</td>
<td>
Floor:
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtFloor" Width="200px" runat="server"
NumberFormat-DecimalDigits="6"
Text='<%# Bind( "Floor") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator ID="rqfFloor" runat="server" ControlToValidate="txtFloor"
Enabled="false"
Display="Dynamic" ErrorMessage="</br>*Floor is Required."
ValidationGroup="VAL" />
</td>
</tr>
<tr>
<td>
Ceiling:
</td>
<td colspan="3">
<telerik:RadNumericTextBox
ID="txtCeiling" Width="200px" runat="server"
NumberFormat-DecimalDigits="6"
Text='<%# Bind( "Ceiling") %>'>
</telerik:RadNumericTextBox>
<asp:RequiredFieldValidator
ID="rqfCeiling" runat="server" ControlToValidate="txtCeiling"
Enabled="false"
Display="Dynamic" ErrorMessage="</br>*Ceiling is Required."
ValidationGroup="VAL" />
</td>
<td>
Trade ID:
</td>
<td colspan="3">
<asp:TextBox
ID="txttradeiddetail" Text='<%# Bind( "TradeID") %>'
runat="server"
Width="200px">
</asp:TextBox>
</td>
</tr>
<tr runat="server" id="Tdetails">
<td>
Termination Date:
</td>
<td colspan="3">
<telerik:RadDatePicker ID="RDITerminationdatedetail" runat="server" Width="200px"
AutoPostBack="false" Calendar-FastNavigationStep="12" DateInput-EmptyMessage=""
MinDate="01/01/1000" MaxDate="01/01/3000">
</telerik:RadDatePicker>
</td>
<td>
Terminated Volume:
</td>
<td colspan="3">
<telerik:RadTextBox
ID="txtTvoldetail" Width="200px" runat="server" Text='<%# Bind(
"breakvol") %>'>
</telerik:RadTextBox>
</td>
</tr>
<tr runat="server" id="Tdetails1">
<td>
New ExternalID:
</td>
<td colspan="3">
<telerik:RadTextBox
ID="txtnewextiddetail" Width="200px" runat="server" Text='<%# Bind(
"newbreakid") %>'>
</telerik:RadTextBox>
</td>
</tr>
</table>
</asp:Panel>
<table style="width: 100%">
<tr>
<td align="center" colspan="2">
<asp:Button ID="Button3"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update"
%>'
OnClientClick="disable_button(this)" ValidationGroup="VAL"
runat="server" CommandName='<%# (Container is GridEditFormInsertItem)
? "PerformInsert" : "Update" %>'>
</asp:Button>
<asp:Button ID="Button4"
Text="Cancel" runat="server" CausesValidation="False"
CommandName="Cancel">
</asp:Button>
</td>
<td>
<asp:Label ID="lblerror"
Font-Size="Small" Font-Bold="true" ForeColor="Red" runat="server"
Text=""></asp:Label>
</td>
<div style="display: none">
<asp:Button ID="Button1"
Text="Finish" runat="server" Visible="true" OnClick="Button3_Click">
</asp:Button>
</div>
</tr>
</table>
</FormTemplate>
</EditFormSettings>
</MasterTableView>
<GroupingSettings CaseSensitive="false" />
</telerik:RadGrid>
javascript that fires update commnd event
function confirmCallBackFn1(arg) {
}
if (arg == true) {
document.getElementById('hdnconfirm').value = "1";
var masterTable = $find("<%= RadGrid2.ClientID %>").get_masterTableView();
masterTable.fireCommand("update", "0");
}
}
Updatecommand event with radconfirm--when i clcik on radconfirm "OK" below event is firing but not able find the edit form controls.
protected void RadGrid2_OnUpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
var insertedItem = e.Item as GridEditFormItem;
if (insertedItem == null)
{
GridDataItem insertedItem1 = (GridDataItem)e.Item;
insertedItem = insertedItem1.EditFormItem;
//e.Item.Edit = true;
//insertedItem.Edit = true;
//GridItem item = (GridItem)RadGrid2.MasterTableView.Items[0]; // Get the first item
//item.Edit = true; // Set in EditMode
//RadGrid2.MasterTableView.Rebind();
for (int i = 0; i < RadGrid1.PageSize; i++)
{
RadGrid2.EditIndexes.Add(i);
}
//foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
//{
// item.Edit = true;
//}
//RadGrid2.Rebind();
}
DateTime Tdate = Convert.ToDateTime(insertedItem["BreakDate"].Text);
RadDatePicker RDIstart = (RadDatePicker)insertedItem.FindControl("RDIStartDate");
if (RDITerminationdatedetail.SelectedDate != Tdate && hdnconfirm.Value == "0")
{
RadWindowManager1.RadConfirm("alert msg", "confirmCallBackFn1", 330, 180, null, "Terminate trade");
return;
}
//update code will follow
}
0
Shinu
Top achievements
Rank 2
answered on 04 Apr 2014, 12:26 PM
Hi Karthik,
I guess you want to access the controls in the EditForm on UpdateCommand. Please try the following code snippet.
C#:
Thanks,
Shinu
I guess you want to access the controls in the EditForm on UpdateCommand. Please try the following code snippet.
C#:
protected
void
RadGrid2_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem edit = (GridEditableItem)e.Item;
RadDatePicker RDIstart = (RadDatePicker)edit.FindControl(
"RDIStartDate"
);
// Access other controls similarly
}
Thanks,
Shinu
0
KARTHIK
Top achievements
Rank 1
answered on 04 Apr 2014, 12:40 PM
Hi Shinu,
Thanks for your quick response.
The above solution is not working for the second time its firing updatecommand event via javascript.still not able find the edit form controls.
Click on first time update will be able to find the controls properly in edit form.after click on radconfirm "OK" will fire same update event not finding the controls.
Thanks
Karthik.A
Thanks for your quick response.
The above solution is not working for the second time its firing updatecommand event via javascript.still not able find the edit form controls.
Click on first time update will be able to find the controls properly in edit form.after click on radconfirm "OK" will fire same update event not finding the controls.
Thanks
Karthik.A
0
Shinu
Top achievements
Rank 2
answered on 05 Apr 2014, 05:12 AM
Hi Karthik,
You are not able to get the controls in the EditForm during second firing of UpdateCommand event because, the Grid is no longer in the Edit mode. First time after the Update command fires, it closes the form, hence the next time Update is called, the Grid is no longer having an editform, hence the controls will not be available in the Update Command.
Thanks,
Shinu
You are not able to get the controls in the EditForm during second firing of UpdateCommand event because, the Grid is no longer in the Edit mode. First time after the Update command fires, it closes the form, hence the next time Update is called, the Grid is no longer having an editform, hence the controls will not be available in the Update Command.
Thanks,
Shinu
0
KARTHIK
Top achievements
Rank 1
answered on 07 Apr 2014, 04:59 AM
Hi Shinu,
Thanks for your response.
Did you have idea to about how to find the controls second time around?or any other options get rad-confirm "ok "click will find the
edit form controls in update command.
Thanks
Karthik.A
Thanks for your response.
Did you have idea to about how to find the controls second time around?or any other options get rad-confirm "ok "click will find the
edit form controls in update command.
Thanks
Karthik.A
0
KARTHIK
Top achievements
Rank 1
answered on 08 Apr 2014, 09:38 AM
Hi shinu,
Do you think any other options available to find the edit form controls when update command fires second time?
Thanks
Karthik.A
Do you think any other options available to find the edit form controls when update command fires second time?
Thanks
Karthik.A
0
Shinu
Top achievements
Rank 2
answered on 08 Apr 2014, 12:13 PM
Hi Karthik,
I guess you want to have a radconfirm on the Update button click. Please try the following code snippet.
ASPX:
C#:
JS:
Thanks,
Shinu
I guess you want to have a radconfirm on the Update button click. Please try the following code snippet.
ASPX:
<
asp:Button
ID
=
"Button3"
Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update"%>' ValidationGroup="VAL" runat="server" CommandName='<%# (Container is GridEditFormInsertItem)
? "PerformInsert" : "Update" %>' ></
asp:Button
>
C#:
protected
void
RadGrid2_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem edit = (GridEditableItem)e.Item;
Button btn = (Button)edit.FindControl(
"Button3"
);
btn.Attributes.Add(
"onclick"
,
"confirmFn('Are you sure you want to delete ??','"
+ edit.ItemIndex +
"'); return false;"
);
}
}
JS:
<script type=
"text/javascript"
>
function
confirmFn(text, index) {
var
callBackFn =
function
(arg) {
if
(arg) {
var
masterTable = $find(
"<%= RadGrid2.ClientID %>"
).get_masterTableView();
masterTable.fireCommand(
"Update"
, index);
}
}
radconfirm(text, callBackFn);
}
</script>
Thanks,
Shinu
0
KARTHIK
Top achievements
Rank 1
answered on 08 Apr 2014, 12:49 PM
Hi shinu,
The above solution is worked partially but not solved my problem.because i want to show the radconfirm only when some date is changes not all the time.
how to achieve that scenario?
i tried below in item data bound. but not working.how to check the date is getting changed or not.then only confirm will show otherwise no need of confirm.
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem edit = (GridEditableItem)e.Item;
DateTime Tdate = Convert.ToDateTime(edit["BreakDate"].Text);
RadDatePicker RDITerminationDate = (RadDatePicker)edit.FindControl("RDITerminationDate");
if (RDITerminationDate.SelectedDate != Tdate)
{
Button btn = (Button)edit.FindControl("Button3");
btn.Attributes.Add("onclick", "confirmFn('Changing the Date for this entry will change the Date for all entries for this trade.','" + edit.ItemIndex + "'); return false;");
}
}
Thanks
Karthik.A
The above solution is worked partially but not solved my problem.because i want to show the radconfirm only when some date is changes not all the time.
how to achieve that scenario?
i tried below in item data bound. but not working.how to check the date is getting changed or not.then only confirm will show otherwise no need of confirm.
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem edit = (GridEditableItem)e.Item;
DateTime Tdate = Convert.ToDateTime(edit["BreakDate"].Text);
RadDatePicker RDITerminationDate = (RadDatePicker)edit.FindControl("RDITerminationDate");
if (RDITerminationDate.SelectedDate != Tdate)
{
Button btn = (Button)edit.FindControl("Button3");
btn.Attributes.Add("onclick", "confirmFn('Changing the Date for this entry will change the Date for all entries for this trade.','" + edit.ItemIndex + "'); return false;");
}
}
Thanks
Karthik.A
0
Shinu
Top achievements
Rank 2
answered on 09 Apr 2014, 04:35 AM
Hi Karthik,
If you want to raise the Radconfirm only if the date is changed, you can use the OnSelectedDateChanged event of the RadDatePicker. Please try the following code snippet:
ASPX:
C#:
JS:
Thanks,
Shinu
If you want to raise the Radconfirm only if the date is changed, you can use the OnSelectedDateChanged event of the RadDatePicker. Please try the following code snippet:
ASPX:
<
telerik:RadDatePicker
ID
=
"RDIStartDate"
runat
=
"server"
AutoPostBack
=
"true"
OnSelectedDateChanged
=
"RDIStartDate_SelectedDateChanged"
>
</
telerik:RadDatePicker
>
C#:
protected
void
RDIStartDate_SelectedDateChanged(
object
sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
{
RadWindowManager1.RadConfirm(
"Changing the Date for this entry will change the Date for all entries for this trade"
,
"confirmCallbackFn"
, 300, 200,
null
,
"Confirm"
);
}
JS:
<script type=
"text/javascript"
>
function
confirmCallbackFn(arg) {
if
(arg)
{
// Your code to do something
}
}
</script>
Thanks,
Shinu
0
KARTHIK
Top achievements
Rank 1
answered on 09 Apr 2014, 12:58 PM
Hi Shinu,
Can you provide code snippet for raise the Radconfirm if the date is changed onclient side and if i click on "OK" will remain the newly selected date, click on "Cancel" will change to OLD date.
I am not able to find the edit form control date picker in java script.
Thanks
Karthik.A
Can you provide code snippet for raise the Radconfirm if the date is changed onclient side and if i click on "OK" will remain the newly selected date, click on "Cancel" will change to OLD date.
I am not able to find the edit form control date picker in java script.
Thanks
Karthik.A
0
Shinu
Top achievements
Rank 2
answered on 10 Apr 2014, 05:31 AM
Hi Karthik,
You may try the following code snippet.
ASPX:
C#:
JS:
Thanks,
Shinu
You may try the following code snippet.
ASPX:
<
asp:HiddenField
ID
=
"HiddenField1"
runat
=
"server"
/>
<
asp:HiddenField
ID
=
"HiddenField2"
runat
=
"server"
/>
C#:
protected
void
RadGrid2_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem edit = (GridEditableItem)e.Item;
RadDatePicker RDIstart = (RadDatePicker)edit.FindControl(
"RDIStartDate"
);
HiddenField1.Value = edit.ItemIndex.ToString();
//store the current edit row index
HiddenField2.Value = RDIstart.SelectedDate.ToString();
// store the date
}
}
protected
void
RDIStartDate_SelectedDateChanged(
object
sender, Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs e)
{
RadWindowManager1.RadConfirm(
"Changing the Date for this entry will change the Date for all entries for this trade"
,
"confirmCallbackFn"
, 300, 200,
null
,
"Confirm"
);
}
JS:
<script type=
"text/javascript"
>
function
confirmCallbackFn(arg) {
if
(!arg) {
debugger;
var
rowindex = document.getElementById(
"HiddenField1"
).value;
var
prevdate = document.getElementById(
"HiddenField2"
).value;
var
masterTable = $find(
"<%= RadGrid2.ClientID %>"
).get_masterTableView();
var
editedItemsArray = masterTable.get_editItems();
var
editFormItem = editedItemsArray[0].get_editFormItem();
var
date = editFormItem.getElementsByTagName(
"input"
)[1];
//check the index of your datepicker,and set accordingly
date.value = prevdate;
}
}
</script>
Thanks,
Shinu
0
KARTHIK
Top achievements
Rank 1
answered on 10 Apr 2014, 07:56 AM
Hi Shinu,
I tried above code snippet but still have issue in finding the radgrid get_dataItems() in javascirpt.
getting below java script error ,
JavaScript runtime error: Object doesn't support property or method 'get_editItems'
please let me know how to fix this.
Thanks
Karthik.A
I tried above code snippet but still have issue in finding the radgrid get_dataItems() in javascirpt.
getting below java script error ,
JavaScript runtime error: Object doesn't support property or method 'get_editItems'
please let me know how to fix this.
Thanks
Karthik.A
0
Shinu
Top achievements
Rank 2
answered on 11 Apr 2014, 06:48 AM
Hi Karthik,
​The client-side properties for getting the tableview insert row and edited rows (get_insertItem(), get_editFormItem(), get_editItems()) are available since Q3 2011.
Please make sure that this the version you are using.
Thanks,
Shinu
​The client-side properties for getting the tableview insert row and edited rows (get_insertItem(), get_editFormItem(), get_editItems()) are available since Q3 2011.
Please make sure that this the version you are using.
Thanks,
Shinu
0
KARTHIK
Top achievements
Rank 1
answered on 15 Apr 2014, 11:46 AM
Hi Shinu,
I am able to find control using below code without get_editItems()
var radGrid = $get("RadGrid2");
datepicker = $telerik.findControl(radGrid, "RDIdatedetail");
i am using telerik 2011 Q2.but after updating 2013 Q3 able to find the control using above method.but
have some issues in telerik 2013 .
In rad grid have identity column visible=false not able to get value .based on id column showing values in editform.after setting display=false able get vale of id Column.
Any other way to get id while edit ?instead of setting display=false because change it to telerik 2013 existing code will break in all pages.
Thanks & regards
Karthik.A
I am able to find control using below code without get_editItems()
var radGrid = $get("RadGrid2");
datepicker = $telerik.findControl(radGrid, "RDIdatedetail");
i am using telerik 2011 Q2.but after updating 2013 Q3 able to find the control using above method.but
have some issues in telerik 2013 .
In rad grid have identity column visible=false not able to get value .based on id column showing values in editform.after setting display=false able get vale of id Column.
Any other way to get id while edit ?instead of setting display=false because change it to telerik 2013 existing code will break in all pages.
Thanks & regards
Karthik.A
0