Hello,
Is there a clientside event where I can iterate through rows or a single row cells and collect all controls from row? Problem is that their ClientIDs may vary depending on where the grid is located and I may not now their names at the moment. I tried to do the following:
"controlName" here is only control name suffix which the same through all my controls. In my case it's "_templateEditControl". I tried OnRowCreated, OnMasterTableViewCreated, OnGridCreated but there are still no controls by the time they fire.
Is there an event which would fire when grid enters edit or insert mode? Or any, where I can iterate through row controls and do something with them.
Thank you.
Is there a clientside event where I can iterate through rows or a single row cells and collect all controls from row? Problem is that their ClientIDs may vary depending on where the grid is located and I may not now their names at the moment. I tried to do the following:
function getRowControls(row, controlName) { var result = Array(); var grid = $find(gridID); var master = grid.get_masterTableView(); var columns = master.get_columns(); for (var i = 0; i < columns.length; i++) { var control = getControlFromCell(row.get_cell(columns[i].get_uniqueName()), controlName); if (control) result.push(control); } return result; }
function getControlFromCell(cell, ctlName) { if (cell == null) return null; var cellControls = cell.getElementsByTagName("*"); for (var a = 0, b = cellControls.length; a < b; a++) { var f = cellControls[a].id; if (f && f.endsWith(ctlName)) { return $find(f); } } return null; }
"controlName" here is only control name suffix which the same through all my controls. In my case it's "_templateEditControl". I tried OnRowCreated, OnMasterTableViewCreated, OnGridCreated but there are still no controls by the time they fire.
Is there an event which would fire when grid enters edit or insert mode? Or any, where I can iterate through row controls and do something with them.
Thank you.
10 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 28 Oct 2011, 04:54 AM
Hello Dmitry,
I am not sure about your requirement. I suppose you want to access the controls in a grid template. One suggestion is you can try in
JS:
You can take a look into the following code library.
Accessing server controls in a grid template on the client
Thanks,
Princy.
I am not sure about your requirement. I suppose you want to access the controls in a grid template. One suggestion is you can try in
OnRowSelecting
client event.JS:
<script type=
"text/javascript"
>
function
OnRowSelecting(sender,args)
{
var
grid = sender;
var
masterTable = grid.get_masterTableView();
var
row = masterTable.get_dataItems();
for
(
var
i = 0; i < row.length; i++)
{
var
txtbox = row[i].findElement(
'TextBox1'
);
alert(txtbox.value);
}
}
</script>
You can take a look into the following code library.
Accessing server controls in a grid template on the client
Thanks,
Princy.
0
Dmitry
Top achievements
Rank 1
answered on 28 Oct 2011, 08:13 AM
Hello Princy,
Thanks for reply but I'm afraid this is not the solution I want. The scenery I use is the following:
1. Row enters edit or insert mode.
2. I enumerate all controls in row and subscribe their valueChanged events. Also I put those control IDs into array
3. When valueChanged fires, I use array to assign some values to some controls in the row
Everything I need are:
1. An event where all controls are already in the row, so I could "extract" them. I know how to get controls from row (example above), but none of those events I have listed above was what I needed.
2. A flag stating if the row in edit or insert mode. I know about row.get_isInEditMode() function but this won't work then row is insert mode.
Thanks for reply but I'm afraid this is not the solution I want. The scenery I use is the following:
1. Row enters edit or insert mode.
2. I enumerate all controls in row and subscribe their valueChanged events. Also I put those control IDs into array
3. When valueChanged fires, I use array to assign some values to some controls in the row
Everything I need are:
1. An event where all controls are already in the row, so I could "extract" them. I know how to get controls from row (example above), but none of those events I have listed above was what I needed.
2. A flag stating if the row in edit or insert mode. I know about row.get_isInEditMode() function but this won't work then row is insert mode.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 28 Oct 2011, 11:05 AM
Hello,
please try with below link and let me if any concern.
http://www.telerik.com/community/forums/aspnet-ajax/grid/set-controls-attribute-like-enable-disable-on-insert-edit-mode-using-jquery.aspx
Thanks,
Jayesh Goyani
please try with below link and let me if any concern.
http://www.telerik.com/community/forums/aspnet-ajax/grid/set-controls-attribute-like-enable-disable-on-insert-edit-mode-using-jquery.aspx
Thanks,
Jayesh Goyani
0
Dmitry
Top achievements
Rank 1
answered on 31 Oct 2011, 01:03 PM
Hello Jayesh,
Thank you, but this is not what I need. Looks like I figured this myself, and the only thing I want to know is how do I detect if the row is insert mode. Function row.get_isInEditMode() will not return true when it's new inserted row.
MAY I HAVE SOME HELP PLEASE?
I don't know what have happened there, maybe I'm in your personal ban list, and I don't see _any_ replies to my recent posts in this forum.
Thank you, but this is not what I need. Looks like I figured this myself, and the only thing I want to know is how do I detect if the row is insert mode. Function row.get_isInEditMode() will not return true when it's new inserted row.
MAY I HAVE SOME HELP PLEASE?
I don't know what have happened there, maybe I'm in your personal ban list, and I don't see _any_ replies to my recent posts in this forum.
0
Hello Dmitry,
Please use the get_isItemInserted() property in order to check if the corresponding GridTableView is currently in insert mode.
I hope this helps.
Regards,
Mira
the Telerik team
Please use the get_isItemInserted() property in order to check if the corresponding GridTableView is currently in insert mode.
I hope this helps.
Regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Dmitry
Top achievements
Rank 1
answered on 03 Nov 2011, 09:25 AM
Thank you for reply.
I know how to check if MasterTableView is in insert mode. I just don't know how to get a ROW which is inserted. There are no row.IsInInsertMode() function or whatever, and that was why I initiated this thread.
I know how to check if MasterTableView is in insert mode. I just don't know how to get a ROW which is inserted. There are no row.IsInInsertMode() function or whatever, and that was why I initiated this thread.
0
Hello Dmitry,
You can use the get_insertItem() property in order to implement the desired functionality.
I hope this helps.
Kind regards,
Mira
the Telerik team
You can use the get_insertItem() property in order to implement the desired functionality.
I hope this helps.
Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Nov 2011, 10:46 AM
Hello,
There is also another method.
for boundcolumn:
Thanks,
Jayesh Goyani
There is also another method.
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox1"
runat
=
"server"
>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox2"
runat
=
"server"
>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
telerik:RadNumericTextBox
ID
=
"RadNumericTextBox3"
runat
=
"server"
>
</
telerik:RadNumericTextBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditFormInsertItem && e.Item.OwnerTableView.IsItemInserted)
{
GridEditFormInsertItem item = (GridEditFormInsertItem)e.Item;
RadNumericTextBox textbox1 = item.FindControl(
"RadNumericTextBox1"
)
as
RadNumericTextBox;
// Get the textbox for column Price
RadNumericTextBox textbox2 = item.FindControl(
"RadNumericTextBox2"
)
as
RadNumericTextBox;
// Get the textbox for column Quantity
RadNumericTextBox textbox3 = item.FindControl(
"RadNumericTextBox3"
)
as
RadNumericTextBox;
// Get the textbox for column "Total", if it is template as shown in aspx
textbox1.Attributes.Add(
"onFocusout"
,
"return show('"
+ textbox1.ClientID +
"','"
+ textbox2.ClientID +
"','"
+ textbox3.ClientID +
"')"
);
textbox2.Attributes.Add(
"onFocusout"
,
"return show('"
+ textbox1.ClientID +
"','"
+ textbox2.ClientID +
"','"
+ textbox3.ClientID +
"')"
);
textbox3.Attributes.Add(
"onfocus"
,
"return show('"
+ textbox1.ClientID +
"','"
+ textbox2.ClientID +
"','"
+ textbox3.ClientID +
"')"
);
}
}
<script type=
"text/javascript"
>
function
show(cntl1, cntl2, cntl3)
{
var
text1 = $find(cntl1);
var
text2 = $find(cntl2);
var
text3 = $find(cntl3);
var
total = text1.get_value() * text2.get_value();
text3.set_value(total);
}
</script>
for boundcolumn:
TextBox textbox1 = item["ColumnUniqueName"].Controls[0]
as
TextBox;
Thanks,
Jayesh Goyani
0
Dmitry
Top achievements
Rank 1
answered on 11 Nov 2011, 03:17 PM
Mira,
There's no get_insertItem() function in masterTableView. I have 2011.2 version.
There's no get_insertItem() function in masterTableView. I have 2011.2 version.
0
Hello Dmitry,
This function will be available in the Q3 2011 release of the RadControls for ASP.NET AJAX which is expected by the end of this week.
Please, give it a try when it comes out and let me know if you need any further assistance.
Kind regards,
Mira
the Telerik team
This function will be available in the Q3 2011 release of the RadControls for ASP.NET AJAX which is expected by the end of this week.
Please, give it a try when it comes out and let me know if you need any further assistance.
Kind regards,
Mira
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now