Welcome Guest Search | Active Topics | Sign In | Register

Passing Dropdownlist selected value to grid Options
nomo
Posted: Friday, August 14, 2009 6:35:02 PM
Rank: Member
Groups: Member

Joined: 4/6/2008
Posts: 11
I have the following grid on which I'm able to edit and save the field "QUANTYTY" with the MaskedEditColumn. I'm also populating the dropdownlist from the database.

The problem is that when I select an item in dropdowlist in the edit mode the value is not passed to the grid for later update. In addition the value dropdownlist of the next row I select changes to the previous dropdownlist selected value. I checked the example but I'm not able to find a solution.

I know I have to get the selected value from the dropdownlist and pass it to the grid but I'm not able to determine how to do it.


Please help me.

Thanks in advance.


THE GRID COLUMNS

<Columns>
<eo:StaticColumn Width="50" HeaderText="<%$ Resources:AppStrings, TC_Date %>" DataField="TRANSACTION_DATE"></eo:StaticColumn>
<eo:MaskedEditColumn Width="50" DataField="QUANTYTY" HeaderText="<%$ Resources:AppStrings, TC_Amount %>">
<MaskedEdit ID="MaskedEdit4" CssClass="body10" runat="server" TextBoxStyle-CssText="BORDER-RIGHT: #7f9db9 1px solid; PADDING-RIGHT: 2px; BORDER-TOP: #7f9db9 1px solid; PADDING-LEFT: 1px; FONT-SIZE: 9px; PADDING-BOTTOM: 1px; MARGIN: 0px; BORDER-LEFT: #7f9db9 1px solid; PADDING-TOP: 2px; BORDER-BOTTOM: #7f9db9 1px solid;">
<eo:MaskedEditSegment IsRequired="True" MinValue="0" MaxValue="1" SegmentType="Number"></eo:MaskedEditSegment>
<eo:MaskedEditSegment IsRequired="True" MinValue="0" MaxValue="9" SegmentType="Number"></eo:MaskedEditSegment>
<eo:MaskedEditSegment Text=":" IsRequired="True"></eo:MaskedEditSegment>
<eo:MaskedEditSegment IsRequired="True" MinValue="0" MaxValue="5" SegmentType="Number"></eo:MaskedEditSegment>
<eo:MaskedEditSegment IsRequired="True" MinValue="0" MaxValue="9" SegmentType="Number"></eo:MaskedEditSegment>
</MaskedEdit>
</eo:MaskedEditColumn>
<eo:StaticColumn Width="100" HeaderText="<%$ Resources:AppStrings, TC_BusinessUnit %>" DataField="BUSINESS_UNIT"></eo:StaticColumn>
<eo:CustomColumn Width="85" DataField="TRANS_CONCEPT" HeaderText="<%$ Resources:AppStrings, TC_Concept %>" ClientSideBeginEdit="on_begin_edit()" ClientSideEndEdit="on_end_edit()" ClientSideGetText="on_column_gettext()">
<EditorTemplate>
<asp:DropDownList id="ddlTime" runat="server" datasourceid="SqlDataTransactionConceptTime" datatextfield="DESCRIPTION" datavaluefield="DESCRIPTION" CssClass="body10" Width="84" >
</asp:DropDownList>
</EditorTemplate>
</eo:CustomColumn>
<eo:StaticColumn Width="100" HeaderText="" DataField="OLD_QUANTYTY" Visible="false"></eo:StaticColumn>
<eo:StaticColumn Width="100" HeaderText="" DataField="OLD_TRANS_CONCEPT" Visible="false"></eo:StaticColumn>
<eo:StaticColumn Width="100" HeaderText="" DataField="DIV1" Visible="false"></eo:StaticColumn>
<eo:StaticColumn Width="100" HeaderText="" DataField="DIV2" Visible="false"></eo:StaticColumn>
<eo:StaticColumn Width="100" HeaderText="" DataField="DIV3" Visible="false"></eo:StaticColumn>

</Columns>

The not working script (based in your example) is

<script type="text/javascript">

function on_column_gettext(column, item, cellValue) {

}

function on_begin_edit(cell) {
//Get the current cell value
var v = cell.getValue();

//Use index 0 if there is no value
if (v == null)
v = 0;

//Load the value into our drop down box
var dropDownBox = document.getElementById("ddlTime");
dropDownBox.selectedIndex = v;
}

function on_end_edit(cell) {
//Get the new value from the drop down box
var dropDownBox = document.getElementById("ddlTime");
var v = dropDownBox.selectedIndex;

//Use null value if user has not selected a
//value or selected "-Please Select-"
if (v == 0)
v = null;

//Return the new value to the grid
return v;
}

</script>

Menon
Posted: Monday, August 17, 2009 12:23:22 PM
Rank: Advanced Member
Groups: Member

Joined: 8/9/2007
Posts: 59
hi There,

If i am not wrong, check this post, it might help you.

http://www.essentialobjects.com/forum/postst3554_Grid-Cell-Value-and-Cell-Text.aspx

Cheers
Menon
nomo
Posted: Monday, August 17, 2009 12:25:46 PM
Rank: Member
Groups: Member

Joined: 4/6/2008
Posts: 11
I got it to work if I use a non datasource based dropdownlist like the following list.

<select id="ddlTime">
<option>-Please Select-</option>
<option>Horrible</option>
<option>Poor</option>
<option>Fair</option>
<option>Good</option>
<option>Excellent</option>
</select>

But if I use the list with a data source I get an "Object Required" error. How should I populate the dropownlist to get it to work?

This is the data source based dropdownlist I've been using.

<asp:DropDownList id="ddlTime" runat="server" datasourceid="SqlDataTransactionConceptTime" datatextfield="DESCRIPTION" datavaluefield="DESCRIPTION" CssClass="body10" Width="84" >
</asp:DropDownList>
eo_support
Posted: Monday, August 17, 2009 12:37:52 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

The "object required" error is often caused by passing the ID of your control to document.getElementById directly, For example, in your case if you were to call document.getElementById("ddlTime"), it would return null and you can get an "object required" error. We are not sure whether this is your case though because you did not provide much detail about the error.

You should always pass ClientID, instead of ID to document.getElementById. In your case, you will need to use FindControl to find ddlTime first, then use dllTime.ClientID to call document.getElementById. You can see Grid -> Features -> Advanced sample for more details (check Page_Load handler).

I believe your one year support period has already expired. So you may wish to consider placing an upgrade order. The new order would bring you to the latest version (2009) and also give you another year of tech support.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.