Telerik Forums
UI for ASP.NET AJAX Forum
5 answers
394 views
Hi, does anybody know whether it is possible to set the VisibleOnPageLOad attribute via client script ? I haven't found an appropriate method in the client side api of the RadWindow.

Thanks very much,
Wolfgang
Georgi Tunev
Telerik team
 answered on 08 Oct 2010
1 answer
147 views
I have a web page and it has one textbox and button. User can enter specific url to textbox and clicking button opens a new telerik window. This popup window has cancel button and clicking that button close the window.

For example: When user navigates http://server1/testpage.aspx then user enters http://server1/newpopup.aspx then clicks open button and popup shows up then user clicks cancel button on the newpopup.aspx page window closes. When user types http://server2/newpopup.aspx popup shows up but clicking cancel button does not close the newpopup window and it gives access denied error message. This is not a cross browsing issue because I am trying to close popup window in the popup window control.

//Open popup
        protected void xcBrowseDes_Click(object sender, EventArgs e)
        {
            string destinationURL = txtDESTURL.Text.ToLower().Trim().TrimEnd(new char[] { '/' });
            ScriptManager.RegisterStartupScript(xcBrowseDes, typeof(string), "alertScript1", "Confirm('" + destinationURL+"');",true);
        }

//javascript
function Confirm(par) {

            var oWnd = radopen(par, "Browse");
            var width = $(window).width();
            if (width > 750)
                width = 750;

            oWnd.setSize(width - 15, $(window).height() - 15); 
            
            oWnd.center(true);
            oWnd.set_modal(false);
        }

//javascript closing popup window
  function GetRadWindowClose() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog 
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; //IE (and Moz as well) 

            oWindow.close();
        } 

I also tried just window.close() javascript method or self.close() but both methods did not close the window.


Georgi Tunev
Telerik team
 answered on 08 Oct 2010
2 answers
266 views
Hello Everyone,

I have a weird problem in editing a detail row from hierarchy grid.

Please check on attached screenshot for reference and for more details.

ASPX:
<rad:RadGrid runat="server" ID="gridCPDiag"
AllowPaging="True" AllowSorting="True"  PageSize="15"       AutoGenerateColumns="False" GridLines="None" BorderStyle="None"            Skin="Outlook" AllowMultiRowEdit="true" AllowMultiRowSelection="true"
OnNeedDataSource="gridCPDiag_NeedDataSource"
OnDetailTableDataBind="gridCPDiag_DetailTableDataBind"
OnInsertCommand="gridCPDiag_InsertCommand"
OnDataBound="gridCPDiag_Databound"
OnUpdateCommand="gridCPDiag_UpdateCommand"
OnItemCreated="gridCPDiag_ItemCreated"
OnDeleteCommand="gridCPDiag_DeleteCommand" OnItemDataBound="gridCPDiag_ItemDataBound"
OnPreRender="gridCPDiag_PreRender" 
OnItemCommand="gridCPDiag_ItemCommand">
            <MasterTableView Name="Master" DataKeyNames="cpd_id" CommandItemDisplay="Top" EditMode="InPlace" Width="100%">
                <CommandItemTemplate>
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                            <td style="width:60%">
                                <div style="padding:3px 4px 3px 4px">
                                    <table border="0" cellpadding="1" cellspacing="1">
                                        <tr style="font: normal 11px tahoma, Verdana, Helvetica, Sans-serif;vertical-align:middle">
                                            <td>
                                                <div class="toolbarIconDivider">|</div>
                                            </td>
                                            <td>
                                                <asp:LinkButton ID="master_btnAdd" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="InitInsert" ><img style="border:0px" alt="" src="../images/addemail.gif" /> Add</asp:LinkButton>
                                                <asp:LinkButton ID="master_lnkPerformInsert" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="PerformInsert" Visible="false"><img style="border:0px" alt="" src="../images/save.gif" /> Save</asp:LinkButton>
                                            </td>
                                            <td>
                                                <div class="toolbarIconDivider">|</div>
                                            </td>
                                            <td>
                                                <asp:LinkButton ID="master_btnEditSelected"  CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="EditSelected" ><img style="border:0px" alt="" src="../images/edit.gif" /> Edit</asp:LinkButton>
                                                <asp:LinkButton ID="master_btnUpdateEdited" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="Update" Visible="false"><img style="border:0px" alt="" src="../images/save.gif" /> Save</asp:LinkButton>
                                                <asp:LinkButton ID="master_btnCancel" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="CancelAll"  Visible="false" CausesValidation="false"><img style="border:0px" alt="" src="../images/cancel.gif" /> Cancel</asp:LinkButton>
                                            </td>
                                            <td>
                                                <div class="toolbarIconDivider">|</div>
                                            </td>
                                            <td>
                                                <asp:LinkButton ID="master_btnDelete" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="Delete" OnClientClick="javascript:return confirm('Are you sure you want to delete this Clinical Pathway?')" ><img style="border:0px" alt="" src="../images/delete.gif" /> Delete</asp:LinkButton>
                                            </td>
                                            <td>
                                                <div class="toolbarIconDivider">|</div>
                                            </td>
                                            <td align="right">
                                               <asp:LinkButton id="master_PrintFriendly" ForeColor="Black" runat="server" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" ><img  style="border:0px" alt="" src="../images/print.gif" /> Printer Friendly Version</asp:LinkButton>
                                            </td>
                                        </tr>
                                    </table>
                                </div>
                            </td>
                        </tr>
                    </table>
                 </CommandItemTemplate>
                 <DetailTables>
                    <rad:GridTableView Name="Detail2"  DataKeyNames="cp_id" DataMember="visit"  CommandItemDisplay="Top" EditMode="InPlace" Width="100%">
                    <CommandItemTemplate>
                        <table width="100%" border="0" cellspacing="0" cellpadding="0">
                            <tr>
                                <td style="width:60%">
                                    <div style="padding:3px 4px 3px 4px">
                                        <table border="0" cellpadding="1" cellspacing="1">
                                            <tr style="font: normal 11px tahoma, Verdana, Helvetica, Sans-serif;vertical-align:middle">
                                                <td>
                                                    <div class="toolbarIconDivider">|</div>
                                                </td>
                                                <td>
                                                    <asp:LinkButton ID="det2_btnAdd" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="InitInsert"><img style="border:0px" alt="" src="../images/addemail.gif" /> Add</asp:LinkButton>
                                                    <asp:LinkButton ID="det2_lnkPerformInsert" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="PerformInsert" Visible="false"><img style="border:0px" alt="" src="../images/save.gif" /> Save</asp:LinkButton>
                                                </td>
                                                <td>
                                                    <div class="toolbarIconDivider">|</div>
                                                </td>
                                                <td>
                                                    <asp:LinkButton ID="det2_btnEditSelected"  CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="EditSelected" ><img style="border:0px" alt="" src="../images/edit.gif" /> Edit</asp:LinkButton>
                                                    <asp:LinkButton ID="det2_btnUpdateEdited" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="Update" Visible="false"><img style="border:0px" alt="" src="../images/save.gif" /> Save</asp:LinkButton>
                                                    <asp:LinkButton ID="det2_btnCancel" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="CancelAll"  Visible="false" CausesValidation="false"><img style="border:0px" alt="" src="../images/cancel.gif" /> Cancel</asp:LinkButton>
                                                </td>
                                                <td>
                                                    <div class="toolbarIconDivider">|</div>
                                                </td>
                                                <td>
                                                    <asp:LinkButton ID="det2_btnDelete" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="Delete"  OnClientClick="javascript:return confirm('Are you sure you want to delete this/these Clinical Pathway Visit Frequency?')" ><img style="border:0px" alt="" src="../images/delete.gif" /> Delete</asp:LinkButton>
                                                </td>
                                            </tr>
                                        </table>
                                    </div>
                                </td>
                            </tr>
                        </table>
                     </CommandItemTemplate>                   
                        <DetailTables>
                            <rad:GridTableView  Name="Detail3" DataKeyNames="cpi_id" DataMember="instruction" CommandItemDisplay="Top" EditMode="InPlace" Width="100%">
                            <CommandItemTemplate>
                            <table width="100%" border="0" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td style="width:60%">
                                        <div style="padding:3px 4px 3px 4px">
                                            <table border="0" cellpadding="1" cellspacing="1">
                                                <tr style="font: normal 11px tahoma, Verdana, Helvetica, Sans-serif;vertical-align:middle">
                                                    <td>
                                                        <div class="toolbarIconDivider">|</div>
                                                    </td>
                                                    <td>
                                                        <asp:LinkButton ID="det3_btnAdd" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="InitInsert" ><img style="border:0px" alt="" src="../images/addemail.gif" /> Add</asp:LinkButton>
                                                        <asp:LinkButton ID="det3_lnkPerformInsert" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="PerformInsert" Visible="false"><img style="border:0px" alt="" src="../images/save.gif" /> Save</asp:LinkButton>
                                                    </td>
                                                    <td>
                                                        <div class="toolbarIconDivider">|</div>
                                                    </td>
                                                    <td>
                                                        <asp:LinkButton ID="det3_btnEditSelected"  CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="EditSelected" ><img style="border:0px" alt="" src="../images/edit.gif" /> Edit</asp:LinkButton>
                                                        <asp:LinkButton ID="det3_btnUpdateEdited" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="Update" Visible="false"><img style="border:0px" alt="" src="../images/save.gif" /> Save</asp:LinkButton>
                                                        <asp:LinkButton ID="det3_btnCancel" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="CancelAll" Visible="false" CausesValidation="false"><img style="border:0px" alt="" src="../images/cancel.gif" /> Cancel</asp:LinkButton>
                                                    </td>
                                                    <td>
                                                        <div class="toolbarIconDivider">|</div>
                                                    </td>
                                                    <td>
                                                        <asp:LinkButton ID="det3_btnDelete" CssClass="mu" onmouseover="this.className='mo'" onmouseout="this.className='mu'" runat="server" CommandName="Delete"  OnClientClick="javascript:return confirm('Are you sure you want to delete this Clinical Pathway Instruction?')" ><img style="border:0px" alt="" src="../images/delete.gif" /> Delete</asp:LinkButton>
                                                    </td>
                                                </tr>
                                            </table>
                                        </div>
                                    </td>
                                </tr>
                            </table>
                            </CommandItemTemplate>
                             
                            <Columns>
                            <rad:GridBoundColumn DataField="cpi_id" HeaderText="CPI_ID" UniqueName="CPI_ID" Visible="false"></rad:GridBoundColumn>
                            <rad:GridBoundColumn DataField="instructions" HeaderText="instructions" UniqueName="instructions" Visible="false"></rad:GridBoundColumn>
                            <rad:GridTemplateColumn HeaderText="Instructions" UniqueName="instructions" DataField="instructions">
                                <ItemTemplate>
                                    <%# DataBinder.Eval(Container.DataItem, "instructions")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="tbIns" runat="server" Text='<%# Bind( "instructions") %>' width="100%" TabIndex="1" TextMode="MultiLine" Rows="4"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="descValidator" Runat="server" Display="Dynamic" ControlToValidate="tbIns" ErrorMessage="* Required Field">
                                </asp:RequiredFieldValidator>
                            </EditItemTemplate>
                            <HeaderStyle Width="90%" />
                            </rad:GridTemplateColumn>
                            <rad:GridTemplateColumn HeaderText="Sort Order" UniqueName="sortorder" DataField="sortorder">
                                <ItemTemplate>
                                    <%# DataBinder.Eval(Container.DataItem, "sortorder")%>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="tbSortOrder" runat="server" Text='<%# Bind( "sortorder") %>' width="30px" TabIndex="2"></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="descValidator2" Runat="server" Display="Dynamic" ControlToValidate="tbSortOrder" ErrorMessage="* Required Field">
                                </asp:RequiredFieldValidator>
                                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" Display="Dynamic" ControlToValidate="tbSortOrder" ErrorMessage="Please enter a valid sort order number." ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
                            </EditItemTemplate>
                            </rad:GridTemplateColumn>
                         </Columns>
                            </rad:GridTableView>
                        </DetailTables>
                     
                    <Columns>
                        <rad:GridBoundColumn DataField="cp_id" HeaderText="CP_ID" UniqueName="CP_ID" Visible="false"></rad:GridBoundColumn>
                        <rad:GridBoundColumn DataField="VisitFrequency" HeaderText="VisitFrequency" UniqueName="VisitFrequency" Visible="false"></rad:GridBoundColumn>
                        <rad:GridClientSelectColumn UniqueName="ClientSelectColumnDetail1"></rad:GridClientSelectColumn>
                        <rad:GridTemplateColumn HeaderText="Visit Frequency" UniqueName="VisitFrequency" DataField="VisitFrequency">
                            <ItemTemplate>
                                <%# DataBinder.Eval(Container.DataItem, "VisitFrequency")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="tbVisit" runat="server" Text='<%# Bind( "VisitFrequency") %>' width="100%" TabIndex="1" ></asp:TextBox>
                                <asp:RequiredFieldValidator ID="descValidator" Runat="server" Display="Dynamic" ControlToValidate="tbVisit" ErrorMessage="* Required Field">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <HeaderStyle Width="80%" />
                        </rad:GridTemplateColumn>
                        <rad:GridTemplateColumn HeaderText="Sort Order" UniqueName="Sortorder" DataField="Sortorder">
                            <ItemTemplate>
                                <%# DataBinder.Eval(Container.DataItem, "Sortorder")%>
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:TextBox ID="tbVisitSortOrder" runat="server" Text='<%# Bind( "Sortorder") %>' width="30px" TabIndex="2" Visible="false"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="descValidator2" Runat="server" Display="Dynamic" ControlToValidate="tbVisitSortOrder" ErrorMessage="* Required Field" >
                            </asp:RequiredFieldValidator>
                            <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" Display="Dynamic" ControlToValidate="tbVisitSortOrder" ErrorMessage="Please enter a valid sort order number." ValidationExpression="^\d+$"></asp:RegularExpressionValidator>
                        </EditItemTemplate>
                        </rad:GridTemplateColumn>               
 
                     </Columns>
                    </rad:GridTableView>
                 </DetailTables>
                  
               <Columns>
                    <rad:GridBoundColumn DataField="cpd_id" HeaderText="CPD_ID" UniqueName="CPD_ID" Visible="False"></rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="short_desc" HeaderText="short desc" UniqueName="short_desc" Visible="False"></rad:GridBoundColumn>
                    <rad:GridTemplateColumn HeaderText="Diagnosis" UniqueName="short_desc" DataField="short_desc">
                        <ItemTemplate>
                            <%# DataBinder.Eval(Container.DataItem, "short_desc")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbDiag" runat="server" Text='<%# Bind( "short_desc") %>' Width="95%" TabIndex="1"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="descValidator" Runat="server" Display="Dynamic" ControlToValidate="tbDiag" ErrorMessage="* Required field">
                            </asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <HeaderStyle Width="20%" />
                    </rad:GridTemplateColumn>
                    <rad:GridTemplateColumn HeaderText="Description" UniqueName="long_desc" DataField="long_desc">
                        <ItemTemplate>
                            <%# DataBinder.Eval(Container.DataItem, "long_desc")%>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbDesc" runat="server" Text='<%# Bind( "long_desc") %>' Width="95%" TabIndex="2"></asp:TextBox>
                        </EditItemTemplate>
                        <HeaderStyle Width="80%" />
                    </rad:GridTemplateColumn>
                 </Columns>      
            </MasterTableView>
    <ClientSettings EnablePostBackOnRowClick="false">
       <Selecting AllowRowSelect="True"/>
       <ClientEvents />
    </ClientSettings>
     </rad:RadGrid>


Below is the C# code for master grid. 
protected void gridCPDiag_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)
{
            if (!e.IsFromDetailTable)
            {
                ClinicalPathway cp = new ClinicalPathway(AgencyId, BranchId);
                DataTable dt = cp.GetClinicalPathwayList();
                gridCPDiag.DataSource = dt.DefaultView;
            }
}
 
protected void gridCPDiag_PreRender(object sender, EventArgs e)
{
            if (gridCPDiag.MasterTableView.IsItemInserted || cpd_id <= 0) return;
 
            int currentPageIndex = gridCPDiag.CurrentPageIndex;
 
            for (int i = 0; i < gridCPDiag.PageCount; i++)
            {
                foreach (GridDataItem item in gridCPDiag.Items)
                {
                    if (cpd_id.Equals(Convert.ToInt32(item["cpd_id"].Text)))
                    {
                        item.Selected = true;
                        currentPageIndex = -1;
                        break;
                    }
                }
 
                if (currentPageIndex.Equals(-1))
                    break;
 
                currentPageIndex++;
                if (currentPageIndex >= gridCPDiag.PageCount)
                    currentPageIndex = 0;
                gridCPDiag.CurrentPageIndex = currentPageIndex;
                gridCPDiag.Rebind();
            }
}
 
protected void gridCPDiag_DetailTableDataBind(object source, Telerik.WebControls.GridDetailTableDataBindEventArgs e)
{
            GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
            switch (e.DetailTableView.DataMember)
            {
                case "visit":
                    {
                        string CPID = dataItem.GetDataKeyValue("cpd_id").ToString();
                        ClinicalPathway cp = new ClinicalPathway(AgencyId, BranchId);
                        DataTable dt = cp.GetVisitFreqByDiag(Convert.ToInt32(CPID));
                        e.DetailTableView.DataSource = dt.DefaultView;
                        break;
                    }
 
                case "instruction":
                    {
                        string CPDID = dataItem.GetDataKeyValue("cp_id").ToString(); 
                        ClinicalPathway cp = new ClinicalPathway(AgencyId, BranchId);
                        DataTable dt = cp.GetInstructionsByVisitFreq(Convert.ToInt32(CPDID));
                        e.DetailTableView.DataSource = dt.DefaultView;
                        break;
                    }
            }
        }
 
 
protected void gridCPDiag_ItemDataBound(object sender, Telerik.WebControls.GridItemEventArgs e)
{
            if (e.Item is GridCommandItem && e.Item.OwnerTableView.Name == "Master")
            {
                GridCommandItem diagcommandItem = (GridCommandItem)e.Item;
                LinkButton diagbtnAdd = (LinkButton)diagcommandItem.FindControl("master_btnAdd");
                LinkButton diaglnkPerformInsert = (LinkButton)diagcommandItem.FindControl("master_lnkPerformInsert");
                LinkButton diagbtnEditSelected = (LinkButton)diagcommandItem.FindControl("master_btnEditSelected");
                LinkButton diagbtnUpdateEdited = (LinkButton)diagcommandItem.FindControl("master_btnUpdateEdited");
                LinkButton diagbtnCancel = (LinkButton)diagcommandItem.FindControl("master_btnCancel");
                LinkButton diagbtnDelete = (LinkButton)diagcommandItem.FindControl("master_btnDelete");
                LinkButton diagbtnPrint = (LinkButton)diagcommandItem.FindControl("master_PrintFriendly");
 
                string printurl = "ClinicalPathways/ClinicalPathwaysrpt.aspx";
                diagbtnPrint.Attributes.Add("onclick", "javascript:window.open('" + printurl + "', '', '');");
 
                if (IsMasterExpanded || IsDetailExpanded)
                {
                    diagbtnAdd.Enabled=false;
                    diagbtnEditSelected.Enabled=false;
                    diagbtnDelete.Enabled = false;
                }
 
                if (hdnCommandName.Value == "master_initinsert" || hdnCommandName.Value == "master_editselected")
                {
                    diagbtnAdd.Visible = false;
                    diagbtnEditSelected.Visible = false;
                    diagbtnDelete.Visible = false;
                    diagbtnCancel.Visible = true;
                }
 
                if (hdnCommandName.Value == "master_initinsert")   
                    diaglnkPerformInsert.Visible = true;
 
                if (hdnCommandName.Value == "master_editselected")
                    diagbtnUpdateEdited.Visible = true;
 
                if (hdnCommandName.Value == "master_performinsert" || hdnCommandName.Value == "master_update" || hdnCommandName.Value == "master_cancelall")
                {
                    diagbtnAdd.Visible = true;
                    diagbtnEditSelected.Visible = true;
                    diagbtnDelete.Visible = true;
                    diaglnkPerformInsert.Visible = false;
                    diagbtnUpdateEdited.Visible = false;
                    diagbtnCancel.Visible = false;
                }
            }
 
            if (e.Item is GridCommandItem && e.Item.OwnerTableView.Name == "Detail2")
            {
                GridCommandItem visitcommandItem = (GridCommandItem)e.Item;
                LinkButton visitbtnAdd = (LinkButton)visitcommandItem.FindControl("det2_btnAdd");
                LinkButton visitlnkPerformInsert = (LinkButton)visitcommandItem.FindControl("det2_lnkPerformInsert");
                LinkButton visitbtnEditSelected = (LinkButton)visitcommandItem.FindControl("det2_btnEditSelected");
                LinkButton visitbtnUpdateEdited = (LinkButton)visitcommandItem.FindControl("det2_btnUpdateEdited");
                LinkButton visitbtnCancel = (LinkButton)visitcommandItem.FindControl("det2_btnCancel");
                LinkButton visitbtnDelete = (LinkButton)visitcommandItem.FindControl("det2_btnDelete");
 
                if (IsDetailExpanded)
                {
                    visitbtnAdd.Enabled = false;
                    visitbtnEditSelected.Enabled = false;
                    visitbtnDelete.Enabled = false;
                }
 
                if (hdnCommandName.Value == "det2_initinsert" || hdnCommandName.Value == "det2_editselected")
                {
                    visitbtnAdd.Visible = false;
                    visitbtnEditSelected.Visible = false;
                    visitbtnDelete.Visible = false;                   
                    visitbtnCancel.Visible = true;
                }
 
                if (hdnCommandName.Value == "det2_initinsert")
                    visitlnkPerformInsert.Visible = true;
 
                if (hdnCommandName.Value == "det2_editselected")
                    visitbtnUpdateEdited.Visible = true;      
                     
                if (hdnCommandName.Value == "det2_performinsert" || hdnCommandName.Value == "det2_update" || hdnCommandName.Value == "det2_cancelall")
                {
                    visitbtnAdd.Visible = true;
                    visitbtnEditSelected.Visible = true;
                    visitbtnDelete.Visible = true;
                    visitlnkPerformInsert.Visible = false;
                    visitbtnUpdateEdited.Visible = false;
                    visitbtnCancel.Visible = false;
                }
 
            }
 
            if (e.Item is GridCommandItem && e.Item.OwnerTableView.Name == "Detail3")
            {
                GridCommandItem inscommandItem = (GridCommandItem)e.Item;
                LinkButton insbtnAdd = (LinkButton)inscommandItem.FindControl("det3_btnAdd");
                LinkButton inslnkPerformInsert = (LinkButton)inscommandItem.FindControl("det3_lnkPerformInsert");
                LinkButton insbtnEditSelected = (LinkButton)inscommandItem.FindControl("det3_btnEditSelected");
                LinkButton insbtnUpdateEdited = (LinkButton)inscommandItem.FindControl("det3_btnUpdateEdited");
                LinkButton insbtnCancel = (LinkButton)inscommandItem.FindControl("det3_btnCancel");
                LinkButton insbtnDelete = (LinkButton)inscommandItem.FindControl("det3_btnDelete");
 
 
                if (hdnCommandName.Value == "det3_initinsert" || hdnCommandName.Value == "det3_editselected")
                {
                    insbtnAdd.Visible = false;
                    insbtnEditSelected.Visible = false;
                    insbtnDelete.Visible = false;
                    insbtnCancel.Visible = true;
                }
 
                if (hdnCommandName.Value == "det3_initinsert")
                    inslnkPerformInsert.Visible = true;
 
                if (hdnCommandName.Value == "det3_editselected")
                    insbtnUpdateEdited.Visible = true;
 
                if (hdnCommandName.Value == "det3_performinsert" || hdnCommandName.Value == "det3_update" || hdnCommandName.Value == "det3_cancelall")
                {
                    insbtnAdd.Visible = true;
                    insbtnEditSelected.Visible = true;
                    insbtnDelete.Visible = true;
                    inslnkPerformInsert.Visible = false;
                    insbtnCancel.Visible = false;
                }
            }
        }
 
protected void gridCPDiag_ItemCommand(object sender, GridCommandEventArgs e)
{
          if (e.CommandName == RadGrid.ExpandCollapseCommandName)
            {
                foreach (GridItem item in e.Item.OwnerTableView.Items)
                {
                    if (item.Expanded && item != e.Item)
                    {
                        item.Expanded = false;
                        this.ExpandedStates.Remove(item.ItemIndexHierarchical);
                        this.ClearExpandedChildren(item.ItemIndexHierarchical);
                    }
                }
 
                if (!e.Item.Expanded)
                {
                    this.ExpandedStates[e.Item.ItemIndexHierarchical] = true;
                }
                else
                {
                    this.ExpandedStates.Remove(e.Item.ItemIndexHierarchical);
                    this.ClearExpandedChildren(e.Item.ItemIndexHierarchical);
                }
 
                if (e.Item.OwnerTableView.Name == "Master")
                {
                    GridCommandItem commandItem = (GridCommandItem)gridCPDiag.MasterTableView.GetItems(GridItemType.CommandItem)[0];
                    LinkButton diagbtnAdd = (LinkButton)commandItem.FindControl("master_btnAdd");
                    LinkButton diagbtnEditSelected = (LinkButton)commandItem.FindControl("master_btnEditSelected");
                    LinkButton diagbtnDelete = (LinkButton)commandItem.FindControl("master_btnDelete");
 
                    if (!e.Item.Expanded)
                    {
                        IsMasterExpanded = true;
                        diagbtnAdd.Enabled = false;
                        diagbtnEditSelected.Enabled = false;
                        diagbtnDelete.Enabled = false;
                    }
                    else
                    {
                        IsMasterExpanded = false;
                        diagbtnAdd.Enabled = true;
                        diagbtnEditSelected.Enabled = true;
                        diagbtnDelete.Enabled = true;
                    }
 
                }
 
                if (e.Item.OwnerTableView.Name == "Detail2")
                {
                    int countOfExpandedItems = 0;
 
                    foreach (GridDataItem masterItem in gridCPDiag.MasterTableView.Items)
                    {
                        IsDetailExpanded = false;
                        if (masterItem.Expanded)
                        {
                            GridCommandItem commandItem = (GridCommandItem)masterItem.ChildItem.NestedTableViews[0].GetItems(GridItemType.CommandItem)[0];
                            LinkButton visitbtnAdd = (LinkButton)commandItem.FindControl("det2_btnAdd");
                            LinkButton visitbtnEditSelected = (LinkButton)commandItem.FindControl("det2_btnEditSelected");
                            LinkButton visitbtnDelete = (LinkButton)commandItem.FindControl("det2_btnDelete");
 
                            countOfExpandedItems += 1;
 
                            visitbtnAdd.Enabled = (e.Item.Expanded && countOfExpandedItems == 1);
                            visitbtnEditSelected.Enabled = (e.Item.Expanded && countOfExpandedItems == 1);
                            visitbtnDelete.Enabled = (e.Item.Expanded && countOfExpandedItems == 1);
                            IsDetailExpanded = true;
                        }                       
                    }                   
                }
            }
 
            if (e.Item.OwnerTableView.Name == "Master")
            {
 
                if (e.Item is GridCommandItem)
                {
                    if (e.CommandName == "InitInsert")
                        hdnCommandName.Value = "master_initinsert";
 
                    if (e.CommandName == "PerformInsert")
                        hdnCommandName.Value = "master_performinsert";
 
                    if (e.CommandName == "EditSelected")
                        hdnCommandName.Value = "master_editselected";
 
                    if (e.CommandName == "Update")
                        hdnCommandName.Value = "master_update";
                     
                    if (e.CommandName == "CancelAll")
                        hdnCommandName.Value = "master_cancelall";
 
                    if (e.CommandName == "Delete")
                        hdnCommandName.Value = "master_delete";
                }
 
            }
                         
            if (e.Item.OwnerTableView.Name == "Detail2")
            {
                if (e.Item is GridCommandItem)
                {
                    GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;
                    SelectedCPDiag = (int)(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["cpd_id"]);
 
                    if (e.CommandName == "InitInsert")
                    {
                        hdnCommandName.Value = "det2_initinsert";
                        if (!e.Item.Expanded)
                            IsMasterExpanded = true;
                        else
                            IsMasterExpanded = false;
                    }
 
                    if (e.CommandName == "PerformInsert")
                    {
                        hdnCommandName.Value = "det2_performinsert";
 
                        GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();                       
                        if (insertedItem.IsInEditMode)
                        {
                            int cpv_id = 0;
                            cpv_id = InsertVisitFreq(insertedItem);
                            e.Item.OwnerTableView.Rebind();
                        }
                    }
 
                    if (e.CommandName == "EditSelected")
                    {
                        hdnCommandName.Value = "det2_editselected";
                        if (!e.Item.Expanded)
                            IsMasterExpanded = true;
                        else
                            IsMasterExpanded = false;
                    }
 
                    if (e.CommandName == "Update")
                    {
                        hdnCommandName.Value = "det2_update";
 
                        GridTableView table = (GridTableView)e.Item.OwnerTableView;
                        foreach (GridEditableItem editItem in table.GetItems(GridItemType.EditItem))
                        {
                            string cpid = editItem.GetDataKeyValue("cp_id").ToString();
                            TextBox txtVisitFreq = (TextBox)editItem.FindControl("tbVisit");
                            TextBox txtVisitSortOrder = (TextBox)editItem.FindControl("tbVisitSortOrder");
 
                            UpdateVisitFreq(cpid, txtVisitFreq.Text, Convert.ToInt32(txtVisitSortOrder.Text));
                            editItem.Edit = false;
                        }
                    }
                     
                    if (e.CommandName == "CancelAll")
                    {
                        hdnCommandName.Value = "det2_cancelall";
 
                    }
 
                    if (e.CommandName == "Delete")
                    {
                        hdnCommandName.Value = "det2_delete";
 
                        GridTableView table = (GridTableView)e.Item.OwnerTableView;
                        foreach (GridDataItem childitem in table.Items)
                        {
                            if (childitem.Selected)
                            {
                                int cpid = Convert.ToInt32(childitem.GetDataKeyValue("cp_id"));
                                string desc = childitem.Cells[3].Text;
                                DeleteVisitFreq(cpid, desc);
                            }
                        }
                        table.Rebind();
                    }
                }
 
            }
 
            if (e.Item.OwnerTableView.Name == "Detail3")
            {
                 
                    GridDataItem parentItem = e.Item.OwnerTableView.ParentItem;
                    SelectedCPVisitFreq = (int)(parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["cp_id"]);
 
                    if (e.CommandName == "InitInsert")
                    {
                        hdnCommandName.Value = "det3_initinsert";
                        if (!e.Item.Expanded)
                            IsDetailExpanded = true;
                        else
                            IsDetailExpanded = false;
                    }
 
                    if (e.CommandName == "PerformInsert")
                    {
                        hdnCommandName.Value = "det3_performinsert";
 
                        GridEditableItem insertedItem = e.Item.OwnerTableView.GetInsertItem();
                        if (insertedItem.IsInEditMode)
                        {
                            int cpi_id = 0;
                            cpi_id = InsertVFIns(insertedItem);
                            e.Canceled = true;
                            e.Item.OwnerTableView.Rebind();
                        }
                    }
 
                    if (e.CommandName == "EditSelected")
                    {
                        hdnCommandName.Value = "det3_editselected";
                        if (!e.Item.Expanded)
                            IsDetailExpanded = true;
                        else
                            IsDetailExpanded = false;
                    }
 
                    if (e.CommandName == "Update")
                    {
                        hdnCommandName.Value = "det3_update";
 
                        GridTableView table = (GridTableView)e.Item.OwnerTableView;
                        foreach (GridEditableItem editItem in table.GetItems(GridItemType.EditItem))
                        {
                            string cpiid = editItem.GetDataKeyValue("cpi_id").ToString();
                            TextBox txtInstr = (TextBox)editItem.FindControl("tbIns");
                            TextBox txtSortOrder = (TextBox)editItem.FindControl("tbSortOrder");
 
                            UpdateVFIns(cpiid, txtInstr.Text, Convert.ToInt32(txtSortOrder.Text));
                            editItem.Edit = false;
                        }
                    }
 
                    if (e.CommandName == "CancelAll")
                    {
                        hdnCommandName.Value = "det3_cancelall";
                    }
 
                    if (e.CommandName == "Delete")
                    {
                        hdnCommandName.Value = "det3_delete";
 
                        GridTableView table = (GridTableView)e.Item.OwnerTableView;
                        foreach (GridDataItem childitem in table.Items)
                        {
                            if (childitem.Selected)
                            {
                                int cpid = Convert.ToInt32(childitem.GetDataKeyValue("cpi_id"));
                                string desc = childitem.Cells[2].Text;
                                DeleteVFIns(cpid, desc);
                            }
                        }
                        table.Rebind();
                    }
                }           
        }

I would really appreciate for any response.

Thanks!
Zel
Maria Ilieva
Telerik team
 answered on 08 Oct 2010
2 answers
129 views
Hello,

I have a simple RadGrid binded with a WCF Web Service like this:
<ClientSettings>
     <DataBinding Location="~/MyWCFWebService.svc" SelectMethod="GetListAndCount" SortParameterType="String" FilterParameterType="String"></DataBinding>
</ClientSettings>

1) I'm wondering how to set a default sort expression (client-side)?

2) Same question to set a default filter (client-side).

3) I noticed the sort behavior is different between server-side and client-side binding mode.
With a server side binding, when you sort a grid column the header back color is changing.
However with client side binding the header back color stays identical.
How is it possible to have same behavior in both case (header back color changing when the column is sorted)?

Thank you

Mike Taylor
Top achievements
Rank 1
 answered on 08 Oct 2010
1 answer
184 views
Hi,
 I have an object with hierarchy displayed below, and I need to bind to this using declarative binding in the ASPX page.

RootObject
   I_ StreetNames (collection)
          I_StreetID
  I_StreetName

Now I need to bind the DataTextField to StreetName and DataValueField to StreetID

Due to our architecture constraint I need to use object data source only. I would like to do a declarative binding.

I had tried the following options
ID="cboStreetName" DataSource='<%# Eval("StreetNames") %>' DataTextField="StreetName" DataValueField="StreetID" with the error
 Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control

DataSource='<%# DataBinder.Eval(Container,"StreetNames") %>' DataTextField="StreetName" DataValueField="StreetID"> with error
ASP.xxx_aspx' does not contain a property with the name 'StreetNames'

I am new to ASP.NET as well as Telerik Combobox.
I am working in ASP.NET 2.0 in Win XP enviroment.

Thanks in Advance
Murthy Meka


Developer
Top achievements
Rank 1
 answered on 08 Oct 2010
7 answers
172 views
Hi,
I am working with Telerik Ajax components of the framework 4.0.
In the web application I have a Master.Page in which I put a script manager in order to manage all ajax controls in  the different pages. in one of the pages in the application I implements a grid with paging and virtual scrolling as shown in the example:
http://demos.telerik.com/aspnet-ajax/grid/examples/client/virtualscrollpaging/defaultcs.aspx
the implementation of virtual scrolling error appears:
Microsoft JScript runtime error: Sys.InvalidOperationException: A Control IS Already With The associated element.
Someone there an idea??
Pavlina
Telerik team
 answered on 08 Oct 2010
2 answers
282 views
Hi all, still have no answer, thus I repost my problem with a more clear title

I have a problem with filtering by GridMaskedColumn.
This is my code:
<telerik:GridMaskedColumn DataField="Customer.PhoneNumbers" DataType="System.String"
                Mask="(###) ###-####" HeaderText="Phone Number" SortExpression="Customer.PhoneNumbers"
                UniqueName="CustomerPhone">
                <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="15%" />
                <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="15%" />
            </telerik:GridMaskedColumn>
The problem is:
- If I enter first three numbers in the filter field - it is filtered fine (see the screenshot ok.jpg)
- but if I enter more then three numbers or whole phone number - the filter does not work at all (see the screenshot fail1.jpg and fail2.jpg)

Any suggestions, please.
Oleksandr
Top achievements
Rank 1
 answered on 08 Oct 2010
1 answer
92 views
  Hello,
in RadControls for ASP.NET AJAX Q3 2008 I use this code to localize grid in Edit mode:
<EditFormSettings>
   <EditColumn UniqueName="EditCommandColumn1" ButtonType="ImageButton" CancelText="Отмена" InsertText="Вставить" UpdateText="Обновить" >
   </EditColumn>
</EditFormSettings>

As I knew, in RadControls for ASP.NET AJAX Q2 2010 I can use *.resx files to localize Grid, but I don`t find any fields in RadGrid.Main.resx witch can help me to localize my Grid in Edit mode.

Thanks for any help,

Andrey.
Tsvetina
Telerik team
 answered on 08 Oct 2010
1 answer
113 views
Hi,
   I am working with RadGrid, usercontrol and Radpanelbar.
1. Actually I have A radGrid 'xyz1' which has usercontrol "ucl1" as it's edit form.
 2. In this Usercontrol "ucl1"  I have RadPanelBar "abc1" and some other web controls.
3. In RadPanelBar "abc1" I have another Usercontrol "ucl2" which contain RadGrid "xyz2" in it.

Now I want to pass 2 parameters from the Radgrid 'xyz1' to the Radgrid "xyz2" on click of edit. On Click of Edit I have to pass the parameters to RadGrid "xyz2" which loads data based on those 2 parameters. Please Help me with this issue. I am unable to load data into that RadGrid "xyz2". Can you Provide me with an example that does this similar process......


Thanks & Regards,
Nithu
Maria Ilieva
Telerik team
 answered on 08 Oct 2010
1 answer
78 views
I would like to display a pie chart with a tooltip for each seriesitem that display a grid. How can I accomplish this? I have seen numerous examples but none that I can get to work for this.

Any help would be greatly appreciated.

Thanks!
Fiko
Telerik team
 answered on 08 Oct 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?