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

[Solved] EnableEmptyListItem not working

7 Answers 198 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saurabh Srivastava
Top achievements
Rank 1
Saurabh Srivastava asked on 20 Aug 2009, 03:45 PM
Hi,

I tried to setup the enable empty list item for my gridddropdowncolumn but it doesnt work. I noticed other posts available on this and supposedly there is a hotfix available. Could you please let me know about this.

Regards,
Saurabh

7 Answers, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 21 Aug 2009, 12:22 PM
Hi Saurabh,

Can you share with us some more details on your scenario, as well as what exactly is not working. We do not have any currently known issues with the EmptyListItem and your version of Telerik.Web.UI.

Regards,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Saurabh Srivastava
Top achievements
Rank 1
answered on 21 Aug 2009, 12:41 PM

Hi Veli,

 

Thanks for the response. Here are my scenario details:

 

1. I have a grid loaded in edit mode. I have only one column editable. That is the griddropdown column.

2. I have setup the required properties for the dropdown column on my aspx page. Find below the snippet

 

<telerik:RadGrid ID="rgMissingJourneys" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"   
                AutoGenerateColumns="False" AutoGenerateDeleteColumn="False" AutoGenerateEditColumn="False" GridLines="None" Skin="Custom"   
                OnNeedDataSource="rgMissingJourneys_NeedDataSource" OnItemDataBound="rgMissingJourneys_ItemDataBound" AllowAutomaticUpdates="false"   
                EnableEmbeddedSkins="false" AllowMultiRowEdit="true" AllowMultiRowSelection="true" OnPreRender="rgMissingJourneys_PreRender" OnItemCommand="rgMissingJourneys_ItemCommand">  
                    <MasterTableView EditMode="InPlace" TableLayout="Auto" CommandItemDisplay="Bottom" CommandItemStyle-HorizontalAlign="Right" CommandItemStyle-Height="40" DataKeyNames="voyage_seq"  > 
                        <Columns> 
                            <telerik:GridBoundColumn UniqueName="VoyageSequence"  HeaderText = "Voyage Sequence" DataField = "voyage_seq" AllowFiltering="false" AllowSorting="false" HeaderStyle-Width="50" ReadOnly="true"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="ShipName"  HeaderText = "Ship Name" DataField = "voyage_ship_full_nm" HeaderStyle-Width="120" ReadOnly="true"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="IMONumber" HeaderText = "IMO Number" DataField = "ship_imo_nbr" AllowFiltering="false" HeaderStyle-Width="50" ReadOnly="true"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="Year"  HeaderText = "Year" DataField = "voyage_year_num" HeaderStyle-Width="80" ReadOnly="true" FilterControlWidth="40" ></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="StartPort" HeaderText = "Start Port" DataField = "start_port" HeaderStyle-Width="120" ReadOnly="true"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="LoadPort" HeaderText = "First Load Port" DataField = "first_load_port" HeaderStyle-Width="120" ReadOnly="true"></telerik:GridBoundColumn> 
                           <telerik:GridBoundColumn UniqueName="EndPort" HeaderText = "End Port" DataField = "end_port" HeaderStyle-Width="120" ReadOnly="true"></telerik:GridBoundColumn> 
                            <telerik:GridBoundColumn UniqueName="BenchCd" HeaderText = "Bench" DataField = "bench_cds" AllowFiltering="false" HeaderStyle-Width="70" ReadOnly="true"></telerik:GridBoundColumn> 
                            <telerik:GridDropDownColumn UniqueName = "CargoType" DataField="grades"  HeaderText = "Cargo Type" AllowFiltering ="false" AllowSorting="false"  ListTextField="CargoTypeName" ListValueField="CargoTypeId" EnableEmptyListItem="true" EmptyListItemText="Please select" EmptyListItemValue="0"></telerik:GridDropDownColumn> 
                        </Columns>   
                        <RowIndicatorColumn> 
                            <HeaderStyle Width="20px" /> 
                        </RowIndicatorColumn> 
                        <ExpandCollapseColumn> 
                            <HeaderStyle Width="20px" /> 
                        </ExpandCollapseColumn> 
                          
                       <CommandItemTemplate> 
                                <asp:Button ID="btnUpdate" Text="Update Records" runat="server" BackColor="#009900" Font-Bold="true" Font-Names="Arial" ForeColor="white" BorderStyle="None" BorderColor="white" Height="25px" CommandName="Update"    
                                    Width="128px" />     
                       </CommandItemTemplate> 
                          
                    </MasterTableView> 
                    <ClientSettings> 
                    </ClientSettings>   
                </telerik:RadGrid> 

3. On the itemdatabound event of the grid, I am assigning the datalist to be populated to this dropdown

  protected void rgMissingJourneys_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
            GridEditableItem eeditedItem = e.Item as GridEditableItem;  
            if (editedItem != null)  
            {  
                GridEditManager editMan = editedItem.EditManager;  
 
                GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("CargoType"));  
                editor.DataSource = cargoTypeList;  
                editor.DataBind();  
                //editor.ComboBoxControl.Items.Insert(0, new RadComboBoxItem("Please select", "0"));  
                //editor.EnableViewState = true;    
       
                  
            }  
        }  
          
    } 

 

4. I have configured the prerender (needed to load grid in edit mode) needdatasource event (needed for data binding) and the itemcommand (needed for data update).

 

Issues: 1. Empty List Item is not working

Issues 2: If I select an item, and navigate to another page of the grid, the selection is not being remembered.

 

 

 

 

0
Saurabh Srivastava
Top achievements
Rank 1
answered on 24 Aug 2009, 10:05 AM
Hi,

Any updates?

Regards,
Saurabh
0
Veli
Telerik team
answered on 24 Aug 2009, 04:06 PM
Hi Saurabh,

When you manually rebind RadComboBox inside RadGrid's ItemDataBound event, the EnableEmptylistItem property does not work automatically after you rebind your combo. If you do not call DataBind(), you will see that your empty list item is applied, but you now do not have your combo items databound.

You will need to manually insert a new RadComboBoxItem. You can find a small web page I have created out of the sample code you sent me. Attached is also the screenshot of RadGrid as set up on my side.

Greetings,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Saurabh Srivastava
Top achievements
Rank 1
answered on 25 Aug 2009, 03:47 PM
Hi Veli,

Thanks for the response. As you can see from the code snippet sent by me, I was already trying to do that. I just wanted to check why the property of the control was not working. Any chance you could look at the 2nd issue please?

Regards,
Saurabh
0
Veli
Telerik team
answered on 26 Aug 2009, 01:04 PM
Hi Saurabh,

I am not sure I understand your second question. In any way, I believe, you rebind your grid on every postback in the PreRender event, so that you put all items in edit mode. RadGrid's persisted settings are all cleared out when you rebind it. Additionally, you are rebinding each combobox when your items are databound (after paging for exampl), which also clears any selected combo values.

Greetings,
Veli
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Saurabh Srivastava
Top achievements
Rank 1
answered on 26 Aug 2009, 01:08 PM
Hi Veli,

Thanks for the response. But I was able to fix the issue with this.

Regards,
Saurabh
Tags
Grid
Asked by
Saurabh Srivastava
Top achievements
Rank 1
Answers by
Veli
Telerik team
Saurabh Srivastava
Top achievements
Rank 1
Share this question
or