Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
152 views

Hi
Environment: RadControls for ASP.NET AJAX Q3 2009 / VS 2008 SP1/IE7/WINXP SP 2. 

I would like to conditionally hide or disallow the Update  in GridEditFormItem for certain users. For Example If the User is 'PR Manager', all add/update/edit/delete options will be available,  for others Radgrid will be read only.

I can hide the command items template without any problem but the problem is  when the Grid is in GridEditFormItem.   Just can't refer  the  EditCommandColumn1  (null exception error occurs) or hide its update text. 
Ideal solution will be if user is not 'PR Manager', only the cancel option will be available in GridEditFormItem. Below is my Radgrid and  Radgrid_Item Command.

Any help will be appreciated...


Thanks

GC_0620

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
 
        if ((Session["SessionUserEmplCategory"].ToString().Trim() != "PR Manager"))  
          
        {  
 
            // This works...  
            if (e.Item is GridCommandItem)  
            {  
                GridCommandItem cmdItem = (GridCommandItem)e.Item;  
               
                LinkButton btnedit = (LinkButton)cmdItem.FindControl("btnEditSelected");  
                btnedit.Visible = false;  
                 
                LinkButton btnupdate = (LinkButton)cmdItem.FindControl("btnUpdateEdited");  
                btnupdate.Visible = false;  
                LinkButton btnadd = (LinkButton)cmdItem.FindControl("BtnInitInsert");  
                btnadd.Visible = false;  
                 
                LinkButton btninsert = (LinkButton)cmdItem.FindControl("btnPerformInsert");  
                btninsert.Visible = false;  
 
                LinkButton btndelete = (LinkButton)cmdItem.FindControl("BtnDelete");  
                btndelete.Visible = false;  
 
                LinkButton btnCancel = (LinkButton)cmdItem.FindControl("btnCancel");  
                btnCancel.Visible = false;  
 
                LinkButton btnRefresh = (LinkButton)cmdItem.FindControl("btnRefresh");  
                btnRefresh.Visible = false;  
 
            }  

            //// Can't Hide the EditCommandColumn or hide its Update text.   
                     
           if (e.Item is  GridEditFormItem  && e.Item.IsInEditMode)  
            {  
            
             /// Allow only Cancel option if not 'PR Manager'

 

 

 

             GridEditFormItem EditFormcmdItem = (GridEditFormItem)e.Item;  
             EditFormcmdItem.FindControl("EditCommandColumn1").Visible = false;  
          }    
        }  

 Rad Grid:

<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="False" 
        AllowSorting="True" 
           '''  
           '''" OnItemDataBound="RadGrid1_ItemDataBound">  
        <MasterTableView DataKeyNames="ID" CommandItemDisplay="Top" Width="100%" Font-Size="11px"> 
 
            <CommandItemTemplate> 
                <div style="padding: 5px 5px;">  
                    Custom command item template&nbsp;&nbsp;&nbsp;&nbsp;  
                    <asp:LinkButton ID="btnEditSelected" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Edit.gif" />Edit selected</asp:LinkButton>&nbsp;&nbsp;  
                    <asp:LinkButton ID="btnUpdateEdited" runat="server" CommandName="UpdateEdited" Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Update.gif" />Update</asp:LinkButton>&nbsp;&nbsp;  
                    <asp:LinkButton ID="btnCancel" runat="server" CommandName="CancelAll" Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Cancel.gif" />Cancel editing</asp:LinkButton>&nbsp;&nbsp;  
                    <asp:LinkButton ID="BtnInitInsert" runat="server" CommandName="InitInsert" Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/AddRecord.gif" />Add new</asp:LinkButton>&nbsp;&nbsp;  
                    <asp:LinkButton ID="btnPerformInsert" runat="server" CommandName="PerformInsert" 
                        Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Insert.gif" /> Add this Attachment</asp:LinkButton>&nbsp;&nbsp;  
                    <asp:LinkButton ID="BtnDelete" OnClientClick="javascript:return confirm('Delete all selected Attachments?')" 
                        runat="server" CommandName="DeleteSelected"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Delete.gif" />Delete selected Attachments</asp:LinkButton>&nbsp;&nbsp;  
                    <asp:LinkButton ID="BtnView" runat="server" CommandName="EditSelected" Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/Preview-icon.png" /> View selected</asp:LinkButton>&nbsp;&nbsp;  
                    <asp:LinkButton ID="btnRefresh" runat="server" CommandName="RebindGrid"><img style="border:0px;vertical-align:middle;" alt="" src="Images/Refresh.gif" />Refresh Attachment list</asp:LinkButton> 
                </div> 
            </CommandItemTemplate> 
            <Columns> 
                '''' ''''  
            </Columns> 
          
            <EditFormSettings> 
          
                <EditColumn InsertText="Insert" UpdateText="Update" UniqueName="EditCommandColumn1"  // Allow only Cancel if user is not 'PR Manager'
                    CancelText="Cancel">  
                </EditColumn> 
                <FormTableButtonRowStyle HorizontalAlign="Right"></FormTableButtonRowStyle> 
            </EditFormSettings> 

        </MasterTableView> 
        <ClientSettings> 
            <Selecting AllowRowSelect="True" /> 
            <ClientEvents OnCommand="gridCommand" /> 
        </ClientSettings> 
    </telerik:RadGrid> 
gc_0620
Top achievements
Rank 1
 answered on 26 Feb 2010
1 answer
520 views
Hi

We have a web app that uses RadComboBoxes in a grid.  The last RadComboBox is right near the right margin of the screen.  On smaller screens when the user clicks on the drop down, the list appears but it is half off the screen to the right.  The browser scrollbar adjusts to the new width, however, when you click on the browser scroll bar to scroll over, the drop down list closes and the browser jumps back to the original width.

Even when using the scroll bar at the bottom of the dropdown list, you are unable to get the right hand scroll bar on the dropdown list to display (you can kind of get around this using the scroll wheel on the mouse).

Needless-to-say, this results in a very poor user experience.  Is there a way to get the dropdown list to respect the dimension of the browser window and only appear within its current bounds?
Yana
Telerik team
 answered on 26 Feb 2010
1 answer
65 views
Hello All,

I am using RadGrid in UserControl, and that user control call from aspx page,

I am using RadGrid with inline editing to insert, and update records, during editing when i click on save button(i.e. Image) that time it will fire the following event, and based on proxyAttendeeAvailable.IsInvitedOrBookedForAnyAgenda(eventAttendeeId, (System.DateTime)rdpDate.SelectedDate, (System.DateTime)rtpTimeFrom.SelectedDate, (System.DateTime)rtpTimeTo.SelectedDate) function result bind the javascipt function and it should fire the javascript function mention below, what was wrong with javascipt binding, and why javascipt function is not executed.

protected void rgAvailability_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
{
    if (!e.Item.OwnerTableView.IsItemInserted)
            {
                AttendeeAvailableDateAndTimeService.AttendeeAvailableDateAndTimeClient proxyAttendeeAvailable = new ePlannerPro2Client.AttendeeAvailableDateAndTimeService.AttendeeAvailableDateAndTimeClient();

                try
                {
                    RadDatePicker rdpDate = e.Item.FindControl("txtAvailableDate") as RadDatePicker;
                    RadTimePicker rtpTimeFrom = e.Item.FindControl("txtTimeFrom") as RadTimePicker;
                    RadTimePicker rtpTimeTo = e.Item.FindControl("txtTimeTo") as RadTimePicker;

                    System.DateTime vsDate = System.Convert.ToDateTime(ViewState["AvailabilityDate"].ToString());
                    System.DateTime vsFromTime = System.Convert.ToDateTime(ViewState["AvailabilityTimeFrom"].ToString());
                    System.DateTime vsToTime = System.Convert.ToDateTime(ViewState["AvailabilityTimeTo"].ToString());

                    System.Guid eventAttendeeId = System.Guid.Empty;

                    if (CurrentUser != null && !CurrentUser.EventAttendeeId.Equals(System.Guid.Empty))
                    {
                        eventAttendeeId = CurrentUser.EventAttendeeId;
                    }

                    if (!vsDate.Equals(rdpDate.SelectedDate) || !vsFromTime.Equals(rtpTimeFrom.SelectedDate) || !vsToTime.Equals(rtpTimeTo.SelectedDate) && !System.Convert.ToBoolean(hfResult.Value))
                    {
                        if (proxyAttendeeAvailable.IsInvitedOrBookedForAnyAgenda(eventAttendeeId, (System.DateTime)rdpDate.SelectedDate, (System.DateTime)rtpTimeFrom.SelectedDate, (System.DateTime)rtpTimeTo.SelectedDate))
                        {
                            StringBuilder controls = new StringBuilder();
                            ImageButton updateBtn = e.Item.FindControl("UpdateButton") as ImageButton;

                            if (updateBtn != null)
                            {
                                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                                sb.Append(@"IsInvited('" + updateBtn.UniqueID + "');");
                                RadScriptManager.RegisterStartupScript(updateBtn, this.GetType(), "PopupUpdateMsg", sb.ToString(), false);
                                                               
                            }
                        }
                    }
                    else
                    {
                        hfResult.Value = "true";
                    }

                    bool isValid = false;

                    if (System.Convert.ToBoolean(hfResult.Value))
                    {
                        isValid = SubmitRecord(source, e);
                    }

                    if (isValid == false)
                    {
                        e.Canceled = true;
                    }
                }
                catch { }
                finally
                {
                    if (proxyAttendeeAvailable != null)
                    {
                        proxyAttendeeAvailable.Close();
                        proxyAttendeeAvailable = null;
                    }
                }
            }
}

<telerik:RadCodeBlock ID="RadCode" runat="server">
    <script language="javascript" type="text/javascript">
        function IsInvited(sender) {
            alert('Is Invited');
            document.getElementById("<%=hfResult.ClientID %>").value = false;

            var valid = confirm("One of the existing agenda falls outside the updated availibility date and time, would you like to continue?");
            if (valid) {
                document.getElementById("<%=hfResult.ClientID %>").value = valid;
                __doPostBack(sender, '');
                return true;
            }

            return false;
        }
</script>
</telerik:RadCodeBlock>

Thanks in Advance
Amit






Mira
Telerik team
 answered on 26 Feb 2010
1 answer
107 views
I have a form that has fields that are decorated using the RadInputManager along with it assigning them client side validation rules for numerics etc.

Below these fields I have a RadGrid that is disjoint in relation to those fields so I would like users to be able to fill in the grid or the fields in any order. I have the Grid set to use InPlace editing however attempting to insert a row in the grid triggers the validation of the InputManager also, how can I make it so the grid does not cause this validation to occur for those controls?
Princy
Top achievements
Rank 2
 answered on 26 Feb 2010
1 answer
104 views
Is it possible to set a template for the each container? For example...I have a set of divs I use to create a flexible (horizontal/vertical) rounded corner box. I want those to surround each item. I see that I can style .rsmItem but is there a way to create a template?
Yana
Telerik team
 answered on 26 Feb 2010
2 answers
83 views
I really like the setup of the context menu at

http://demos.telerik.com/aspnet-ajax/grid/examples/generalfeatures/headercontextmenu/defaultcs.aspx

but unless I am blind, the code for the context menu is missing from the aspx.  Would someone please either point me to it or post it here?

Or...is the EnableHeaderContextMenu a built-in replacement for the old RadContextMenu?

Ahhh...nevermind...I just tested it.  Very, very cool!

Thanks,
Mark
Mira
Telerik team
 answered on 26 Feb 2010
1 answer
136 views

Hi,

In Rad grid Control, There are 3 Template Columns (Start time ,end time and Today ) and it has two Rad Time Picker control for      Edit Item Template and check box for Today column.

I'm using the master page as well.

<telerik:GridTemplateColumn HeaderText="Starttime" UniqueName="Starttime" >     
            <EditItemTemplate>     
                <telerik:RadTimePicker ID="rtpStartTime" runat="server">      
                </telerik:RadTimePicker>     
             </EditItemTemplate>     
            <ItemTemplate>     
                <asp:Label ID="lblStarttime" runat="server" Text='<%# Eval("StartTime","{0:t}") %>'></asp:Label>     
            </ItemTemplate>     
        </telerik:GridTemplateColumn>     
              
         <telerik:GridTemplateColumn HeaderText="End time" UniqueName="EndTime">      
            <EditItemTemplate>     
                <telerik:RadTimePicker ID="rtpEndTime" runat="server"        
                </telerik:RadTimePicker>                      
            </EditItemTemplate>     
            <ItemTemplate>     
                <asp:Label ID="lblEndTime" runat="server" Text='<%# Eval("EndTime", "{0:t}") %>'></asp:Label>     
            </ItemTemplate>    
 </telerik:GridTemplateColumn> 
 
<telerik:GridTemplateColumn HeaderText="Today" UniqueName="Today">      
            <EditItemTemplate>     
                <asp:CheckBox ID="CheckBox1"  runat="server"> 
            </asp:CheckBox>                     
            </EditItemTemplate>     
            <ItemTemplate>     
                <asp:CheckBox ID="CheckBox2"  runat="server" Checked='<%# Eval("Today") %>'> 
            </asp:CheckBox> 
            </ItemTemplate>  
 </telerik:GridTemplateColumn>   

I want to validate that end time value is greater than the start time when today check box was checked.

how to use the validation control, and how to show the error messages in validation summary?.

Can you plz tell me the way of doing this.because this is urgent.

thanks
waruni
Mira
Telerik team
 answered on 26 Feb 2010
1 answer
80 views
I have a radgrid in repeater which is having a clientselect column and AllowMultiRowSelection set to False. Single row selection is working fine but unchecking the selected row cannot de selects it.
Shinu
Top achievements
Rank 2
 answered on 26 Feb 2010
3 answers
94 views
Dear Sir:
   I am using 2008Q3 and i found a problem with the radgrid. When I group more then one column and the grip will mess up
there is no problem with IE7 but not for IE8. is there any solution for it. will the latest version telerik will solve the problem?


From CH
Tsvetoslav
Telerik team
 answered on 26 Feb 2010
3 answers
91 views
I've had this working before, though cannot remember how long ago, certainly with the first version of Telerik Controls Q3 2009 but not under the current SP3 (2009.3.1314.35).

.... this works fine when adding a link this way.

 

<Links> 
   <telerik:EditorLink Name="test2" Href="/"></telerik:EditorLink> 
</Links> 

 

 

 


... the following in its most basic form seems to have stopped working, at least in my MVC project:
 
var test = new EditorLink(){ Name = "test", Href="/"};  
this.RadEditor.Links.Add(test);  
                 

Is this a new bug, also Rad Editor 2010 Q1 Beta is experiencing the same problems?
I will be creating another test project to test this as well.
Matthew Green
Top achievements
Rank 1
 answered on 26 Feb 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jake
Top achievements
Rank 1
RBarnes
Top achievements
Rank 1
Iron
Iron
Rami
Top achievements
Rank 1
Iron
Veteran
Nathan
Top achievements
Rank 1
Kumeri
Top achievements
Rank 1
Iron
Veteran
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?