Welcome Guest Search | Active Topics | Sign In | Register

eo:CustomColumn in eo:Grid Options
MedEx
Posted: Thursday, July 23, 2009 10:10:21 AM
Rank: Newbie
Groups: Member

Joined: 7/21/2009
Posts: 3
Hello,

I need a Dropdownlist box in Grid Control which is populating values from Database.

<eo:CustomColumn DataField="DoctorName" HeaderText="Doctor Name">
<EditorTemplate>

<asp:DropDownList ID="drpDoctorName" runat="server">
</asp:DropDownList>

</EditorTemplate>
</eo:CustomColumn>

I am able to view the data's in a normal format. I need to view it in a Drop Down List.

Thanks,
MedEx
eo_support
Posted: Thursday, July 23, 2009 10:25:40 AM
Rank: Administration
Groups: Administration

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

This sample is a good starting point:

http://demo.essentialobjects.com/Default.aspx?path=Grid\_i1\grid_custom_column

Two key points are:

1. Each cell is either in "Displaying" mode or in "Editing" mode. Only a single cell or row can be in edit mode. All other cells are in "displaying" mode. "Displaying" is mainly controlled by DataFormat. It has nothing to do with CustomColumn. So before you jump into the water, you want to know whether you are trying to change "Displaying" or "Editing";

2. CustomColumn is used to provide custom editing UI, so it only affect edit mode. The basic idea is, once you use a CustomColumn, you are in full control. You can put a DropDownList, a Button, or whatever inside the columns' EditorTemplate. The Grid does not care. This also means whatever you put inside EditorTemplate, you need to code to make it work (for example, to fill your drop down list). The Grid does not do anything for you.

Thanks!
MedEx
Posted: Thursday, July 23, 2009 3:20:38 PM
Rank: Newbie
Groups: Member

Joined: 7/21/2009
Posts: 3

<eo:Grid ID="Grid1"
runat="server"
AllowPaging="true"
KeyField="DoctorId"
ColumnHeaderDescImage="00050105"
GridLineColor="220, 223, 228"
Width="380px" IsCallbackByMe="True"
ColumnHeaderAscImage="00050104"
Height="200px"
Font-Size="8.75pt"
Font-Names="Tahoma"
ColumnHeaderDividerImage="00050103"
FullRowMode="False"
>


<Columns>
<eo:StaticColumn DataField="DoctorName" HeaderText="Doctor Name">
</eo:StaticColumn>
<eo:StaticColumn DataField="DEA" HeaderText="DEA">
</eo:StaticColumn>


<eo:CustomColumn Width="120" HeaderText="Doctor Name">
<EditorTemplate>

<asp:DropDownList ID="drpDocName" runat="server"
DataSourceID="sqlDropdownList" DataTextField="DoctorName" Visible ="true"
DataValueField="DoctorID">
</asp:DropDownList>
<asp:SqlDataSource ID="sqlDropdownList" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnString %>"
SelectCommand="SELECT [DoctorID], [DoctorName] FROM [Doctors]">
</asp:SqlDataSource>
</EditorTemplate>
</eo:CustomColumn>
</Columns>

</eo:Grid>


In the above Grid Control, I have a Custom column - Dropdownlist box.
Here i need to populate values from Database. I am able to populate the values in the Dropdownlist Box.

Issue :- Values which are populated in the Dropdownlist box is not displaying - Statically in the Grid. Once i moved from one row, i am not able to view dropdownlist box or the values populated in that column.

I am bit confused.
eo_support
Posted: Thursday, July 23, 2009 3:29:26 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
MedEx wrote:
I am able to populate the values in the Dropdownlist Box.

MedEx wrote:
Issue :- Values which are populated in the Dropdownlist box is not displaying. - Statically in the Grid.

Can you clarify these two conflicting statements? How do you know you have populated them while they are not displaying? I noticed your second statement mentioned about "statically". I am not sure whether that means "displaying" mode. As we have already explained in our previous post, "displaying" mode has nothing to do with EditorTemplate.


MedEx wrote:
Once i moved from one row, i am not able to view dropdownlist box or the values populated in that column.

I don't really know what you mean by this. Please elaborate.

Thanks
MedEx
Posted: Thursday, July 23, 2009 4:21:48 PM
Rank: Newbie
Groups: Member

Joined: 7/21/2009
Posts: 3
Grid has three columns :-

2 Static Column and 1 Custom Column.

I kept a Dropdown List Box in the Custom Column.

I am able to view data's in the Static Column and Values are populating in the drop down List box.

Issue :-

When i am clicking on the Custom Column, a dropdownlist box appears with values.
Though i have selected a value in the drop down list box, As soon as i moved from that column - Value is not visible.

In general, I am not able to view values in the Custom Column.

eo_support
Posted: Thursday, July 23, 2009 4:41:57 PM
Rank: Administration
Groups: Administration

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

That is very normal. Please check your code that saves the value back to the Grid.

Assume that you wish to have a drop down list for user to select U.S. state, the sequence of the events is:

1. The Grid loads its initial data. All cells in display mode. At this stage your DropDownList is not visible;
2. You click a cell, the cell enters edit mode. Just for demonstration purpose, say the cell already has value "NY" in it;
3. If the cell you clicked is a CustomColumn, your EditorTemplate is displayed. At this point you will see your DropDownList;
4. The Grid calls your columns ClientSideBeginEdit handler. You can use this handler to initialize your DropDownList. In this case, you may want to set your DropDownList's current selected item to "NY" so that it shows what the Grid original has;
5. User changes the value, for example, changes it from NY to CA. This step is of course optional;
6. User leaves edit mode (for example, by clicking another cell). The Grid calls your ClientSideEndEdit to ask you "what's the new value?". You have to get the new value from your DropDownList and pass it back to the Grid. If you don't respond this question, the Grid will keep its original value, in this case "NY" and still displays "NY" after the DropDownList is gone;
7. The Grid hides the DropDownList since the cell is no longer in edit mode;

In your case, you want to check step 6 first because that's most likely where your code broke. You will need both DHTML and JavaScript experience to handle that part because the handler requires you to get the value from your DHTML element (your DropDownList box) and pass it back to the Grid with JavaScript.

You can also find more information about CustomColumn here:

http://doc.essentialobjects.com/library/1/grid/custom_column.aspx

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.