This is a migrated thread and some comments may be shown as answers.

hidden field value lost

9 Answers 452 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
newbie
Top achievements
Rank 1
newbie asked on 12 Aug 2008, 11:16 PM
I am not sure under which section this post should go...but it would be great if you could help me find a solution.

I have a hidden field inside an AJAXpanel alongwith a grid and other controls.
The grid has 2 dropdown controls. On the clientselectedindexchanged event of the frist dropdown I put the selection in a hidden field.

On the items requested event of the second dropdown i want to read the value from that hidden field and filter the dropdown.

I am able to set the value of the hidden filed.
But on the itemsrequested evnt for the second combo the hidden field loses the value. I also tried this with a textbox with its display set to none.

If I force a postback in my javascript function then the value in hidden field shows.
I know it has something to do with the AJAX postback but I am not sure how I can work around this.

Any help would be appreciated.

9 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 14 Aug 2008, 12:22 PM
Hi newbie,

You need to use the context object to pass the information to the ItemsRequested event.

Here are some useful links:
I hope this will get you started.

Sincerely yours,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
newbie
Top achievements
Rank 1
answered on 14 Aug 2008, 06:56 PM
Thanks that would work.
The only issue is the combo boxes are inside a grid.
Can you show me an example of how to find the corresponding combo box in the same row of the grid when i click another combo in that row?
0
Veselin Vasilev
Telerik team
answered on 18 Aug 2008, 07:47 AM
Hello newbie,

One of the possible approaches is to use the Telerik.Web.UI.RadComboBox.ComboBoxes array.
Telerik.Web.UI.RadComboBox.ComboBoxes[0] represents the first combobox
Telerik.Web.UI.RadComboBox.ComboBoxes[1] represents the second combobox

I hope this helps.

Kind regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
newbie
Top achievements
Rank 1
answered on 18 Aug 2008, 05:01 PM
how do I use that in javascript?
can you show me an example.
0
newbie
Top achievements
Rank 1
answered on 18 Aug 2008, 06:10 PM
I went through this article :
http://www.telerik.com/community/code-library/submission/b311D-bdgkmc.aspx

with any of the approaches , how will I know which is the combo in a particular row.

these are my two combos inside the grid:

<

telerik:GridTemplateColumn HeaderStyle-Width="175px" SortExpression="TimeID" HeaderText="Time" DataField="TimeID" UniqueName="TimeID" Visible="true">

<ItemTemplate>

<%

# Eval("TimeDisplayValue")%>

</ItemTemplate>

<EditItemTemplate>

<telerik:RadComboBox ID="ddlTime" runat="server" Width="165px" EnableEmbeddedSkins="false" Skin="UTC" EnableLoadOnDemand="true" MarkFirstMatch="true" ToolTip="Select time" CausesValidation="false" EnableVirtualScrolling="true" AllowCustomText="false" AutoPostBack="false" OnItemsRequested="ddlTime_ItemsRequested" TabIndex="1" >

</telerik:RadComboBox>

</EditItemTemplate>

</telerik:GridTemplateColumn>

<telerik:GridTemplateColumn ItemStyle-VerticalAlign="Middle" HeaderStyle-Width="175px" SortExpression="AssignID" HeaderText="Assign" DataField="AssignID" UniqueName="AssignID" Visible="true">

<ItemTemplate>

<%

# Eval("AssignmentDisplayValue")%>

</ItemTemplate>

<EditItemTemplate>

<telerik:RadComboBox ID="ddlAssign" runat="server" Width="165px" EnableEmbeddedSkins="false" Skin="UTC" EnableLoadOnDemand="true" MarkFirstMatch="true" ToolTip="Select assignment" CausesValidation="false" AllowCustomText="false" OnItemsRequested="ddlAssign_ItemsRequested" OnClientItemsRequesting="GetSelectedItem" TabIndex="5" >

</telerik:RadComboBox>

</EditItemTemplate>

</telerik:GridTemplateColumn>


My javascript function:

function

GetSelectedItem(sender, eventArgs)

{

//get the text of the selected item in the first (time) combobox

//var timeValue = timeCombo.get_value();

?????

var context = eventArgs.get_context();

//set the text of the time combobox to the ClientDataString property of the second (assign) combo

context[

"FilterString"] = timeValue;

//then, you will be able to get the text of the time combo in the ItemsRequested event of the second (assign) combobox

}

I am able to get to the rest of the code.
I don't understand how to get the selected value of the timeCombo.
I am unable to get a reference to the timeCombo.

I would greatly appreciate if you could show me with the help of an example.

When I click on the assignment combo i want to get a reference of the time combo in that row itself.
0
Veselin Vasilev
Telerik team
answered on 21 Aug 2008, 02:25 PM
Hello newbie,

When you are in EditMode there are only two comboboxes on the page - the first one is the timeCombo and the second one is assignCombo.

In the GetSelectedItem method you can access the timeCombo in this way:

var timeCombo =
Telerik.Web.UI.RadComboBox.ComboBoxes[0];

Now, timeCombo will hold the reference to the first combobox on the page.
Now you can get the selected value by:

var value = timeCombo.get_value();

Let me know if this helps.

Regards,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
newbie
Top achievements
Rank 1
answered on 21 Aug 2008, 06:33 PM
thanks for that code.
But I forgot to mention that I always display my grid in edit mode.

So all the rows have two combos.
I did a workaround... In the onclientItemsrequesting event of the second combo I have this code.

var

assignComboId = sender._inputDomElement.id;

var timeComboId = assignComboId.replace(/_ddlAssignment_Input/gi, "_ddlTimecode");

//get the text of the selected item in the first (timecode) combobox

var timecodeValue = $find(timeComboId)._value;

I am not sure if this is the most appropriate way of doing this, but this works for me. (However getting the InputDomElement ID bothers me a little.I couldn't get to the client id of the combo in any way)
If there is a better way of doing this please let me know and I'll be glad to implement it.

0
kollam2003
Top achievements
Rank 1
answered on 22 Aug 2008, 05:07 AM
Hai,
Using java script we can get the combo box as
document.getElementById(radCmbSchoolName.InputID).value

Kollam2003
0
Veselin Vasilev
Telerik team
answered on 22 Aug 2008, 07:36 AM
Hi guys,

I recommend that you do not use private methods or members as _value , _inputDomElement.

We expose public methods that you need to use like:

var assignComboId = sender.get_inputDomElement().id;   
 
var timeComboId = assignComboId.replace(/_ddlAssignment_Input/gi, "_ddlTimecode");   
 
//get the text of the selected item in the first (timecode) combobox   
var timecodeValue = $find(timeComboId).get_value();  
 


Greetings,
Veskoni
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Ajax
Asked by
newbie
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
newbie
Top achievements
Rank 1
kollam2003
Top achievements
Rank 1
Share this question
or