Telerik Forums
UI for ASP.NET AJAX Forum
6 answers
172 views
HI,

I need to traverse through radgrid dataitems on client to perform some logic.  It looks like my code works fine in readonly and update mode, however it does not work when
I am trying to insert any item in the grid.  Basically I do not know how to get reference to the "to be inserted item".

For example, if I am inserting first item in the grid then
masterTableView.get_dataItems().length returns 0.
So the Question is:
1. how do I reference the "To be inserted item"
2. how do I get a reference an element/control inside "To be inserted item")
Please Help...

Here is my javascript function:
function getTaxableOrderSubTotal()
{
     
    var taxableOrderSubTotalAmnt = 0.00;
    var radGrid = $find('<%= RadGrid1.ClientID %>');
    var masterTableView;
    var tableViewRows;
    var length = 0;
 
    if (radGrid) {
        masterTableView = radGrid.get_masterTableView();
    }
    if (masterTableView) {
        tableViewRows = masterTableView.get_dataItems();
    }
 
    if (tableViewRows) {
        length = tableViewRows.length;
    }
 
    if (masterTableView) {
        if (length > 0) {
            for (var i = 0; i < length; i++) {
                var dataItem = masterTableView.get_dataItems()[i];
                var isLITaxable = false;
 
                if (dataItem) {
                    // 1. Get Taxable Check box value
                    var chkTxbl = dataItem.findElement("chkTaxableLI");
                    var liTotalPrice = 0.00;
 
                    if (chkTxbl && chkTxbl.checked) {
 
                        // Get Total lineITem Price:
                        // if litTotalPrice control is found the
                        //item is in readonly mode
                        // if txtTotalPrice control is found then
                        // item is in edit mode
                        if (dataItem.findElement("litTotalPrice")) {
                            liTotalPrice = dataItem.findElement("litTotalPrice").value;
                        }
                        else if (dataItem.findElement("txtTotalPrice")) {
                            liTotalPrice = dataItem.findElement("txtTotalPrice").value;
                        }
 
                        taxableOrderSubTotalAmnt = parseFloat(taxableOrderSubTotalAmnt) + parseFloat(liTotalPrice);
                    }
                }
            }
        }

    }
 
    return taxableOrderSubTotalAmnt;
}
Jeremy
Top achievements
Rank 1
 answered on 07 Jun 2011
1 answer
120 views
I am trying to rebind a "cb_SAACode" when "cb_bondClass" selected index is changed.  "cb_SAACode" seems to be rebinding but it is not refreshing on the page.  I tried to use the "FindControl" method to find "cb_SAACode" but it doesn't seem to help at all.  Attached are the code snippets. Note, this is not the full code so it will not compile. Thanks for the help.

Front-end
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script>...</script>
    </telerik:RadCodeBlock>
 
    <asp:Panel ID="pnltest" runat="server">
        <telerik:RadAjaxManager ID="RAManager1" EnableAJAX="true" runat="server" OnAjaxRequest="RAManager1_AjaxRequest">
        </telerik:RadAjaxManager>
        <asp:UpdatePanel ID="testUP" runat="server" UpdateMode="Always" class="showcreation">
            <ContentTemplate>
                <fieldset class="fieldsetwidth">
                    <table class="fTable">
                        <tr>
                            <td>
                                <asp:Label ID="lbl_BondClass" runat="server" Text="Bond Class:" />
                            </td>
                            <td>
                                <telerik:RadComboBox ID="cb_bondClass" runat="server" OnDataBinding="cb_BC_DataBinding"
                                    AutoPostBack="true" OnSelectedIndexChanged="cb_bondClass_SelectedIndexChanged"
                                    SkinID="BondClassRadComboBox">
                                    <HeaderTemplate>
                                        <ul>
                                            <li class="bondClassColOne">Bond Class </li>
                                            <li class="bondClassColTwo">Description </li>
                                        </ul>
                                    </HeaderTemplate>
                                    <ItemTemplate>
                                        <ul>
                                            <li class="bondClassColOne">
                                                <%# DataBinder.Eval(Container, "Text")%>
                                            </li>
                                            <li class="bondClassColTwo">
                                                <%# DataBinder.Eval(Container, "Attributes['Description']")%>
                                            </li>
                                        </ul>
                                    </ItemTemplate>
                                </telerik:RadComboBox>
                            </td>
                        </tr>
                    </table>
                </fieldset>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <telerik:RadPanelBar ID="rpb_BondCreation" runat="server" ExpandMode="MultipleExpandedItems"
        Width="727" Skin="Simple">
        <Items>
            <telerik:RadPanelItem Text="Statistics" Expanded="false" runat="server">
                <Items>
                    <telerik:RadPanelItem Value="Statistics" runat="server">
                        <ContentTemplate>
                            <table class="formContent" cellspacing="1">
                                <tr>
                                    <td>
                                        <asp:ValidationSummary ID="ValidationSummary2" runat="server" HeaderText="There were errors on the page:"
                                            DisplayMode="BulletList" ShowMessageBox="true" ValidationGroup="vg_btn_CalculatePremium"
                                            ShowSummary="false" />
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                        <table>
                                            <tr>
                                                <td>
                                                    <asp:Label ID="lbl_SAACode" runat="server" Text="SAA Code:" />
                                                </td>
                                                <td>
                                                    <telerik:RadComboBox ID="cb_SAACode" runat="server" HighlightTemplatedItems="true"
                                                        Skin="Simple" DropDownWidth="600px" EnableLoadOnDemand="True" Width="100px" OnClientSelectedIndexChanged="fillSAACode"
                                                        OnDataBound="cb_SAACode_DataBound">
                                                        <HeaderTemplate>
                                                            <table>
                                                                <tr>
                                                                    <td style="width: 50px">
                                                                        SAA
                                                                    </td>
                                                                    <td style="width: 300px">
                                                                        DESC
                                                                    </td>
                                                                    <td style="width: 150px">
                                                                        GENERAL
                                                                    </td>
                                                                    <td style="width: 100px">
                                                                        RATECLASS
                                                                    </td>
                                                                    <td style="visibility: collapse;">
                                                                        SAACODEEFF
                                                                    </td>
                                                                    <td style="visibility: collapse;">
                                                                        SAACODEDIS
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <table>
                                                                <tr>
                                                                    <td style="width: 150px" id="saaVal">
                                                                        <%# DataBinder.Eval(Container, "Value")%>
                                                                    </td>
                                                                    <td style="width: 200px" id="saaDesc">
                                                                        <%# DataBinder.Eval(Container, "Text")%>
                                                                    </td>
                                                                    <td style="width: 150px" id="saaClass">
                                                                        <%# DataBinder.Eval(Container, "Attributes['GENERAL']")%>
                                                                    </td>
                                                                    <td style="width: 50px" id="saaRate">
                                                                        <%# DataBinder.Eval(Container, "Attributes['RATECLASS']")%>
                                                                    </td>
                                                                    <td style="visibility: collapse;">
                                                                        <%# DataBinder.Eval(Container, "Attributes['SAACODEEFF']")%>
                                                                    </td>
                                                                    <td style="visibility: collapse;">
                                                                        <%# DataBinder.Eval(Container, "Attributes['SAACODEDIS']")%>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </ItemTemplate>
                                                    </telerik:RadComboBox>
                                                    <asp:RequiredFieldValidator ID="saacodevalidator" runat="server" ControlToValidate="cb_SAACode"
                                                        ValidationGroup="vg_btn_process" ErrorMessage="SAA Code is required." Display="None">
                                                    </asp:RequiredFieldValidator>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                            <%# DataBinder.Eval(Container, "Value")%>
                        </ContentTemplate>
                    </telerik:RadPanelItem>
                </Items>
            </telerik:RadPanelItem>
        </Items>
    </telerik:RadPanelBar>
</asp:Content>


Back-end
namespace BSGSuretyRewrite.BondCreation
{
    [System.Web.Script.Services.ScriptService]
    public partial class BondCreation : System.Web.UI.Page
    {
        public string mError = string.Empty;
 
        public string sRollback = Environment.NewLine + " IF @@error <> 0  BEGIN ROLLBACK TRANSACTION RETURN END " + Environment.NewLine;
 
        public string qBType;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            
            if (!Page.IsPostBack)
            {
                cb_IssuedBy.DataBind();
                ddl_TerminationProvisions.Attributes.Add("onChange", "onSelect();");
                this.btn_ClearAddress.Attributes["onClick"] = "return false;";
                cb_SameAddress.Attributes.Add("onclick", "javascript:OnCheck_Changed(this);");
 
                int bidNum = int.Parse(Request.QueryString["BidNum"]);
                qBType = Request.QueryString["bType"];
 
                cb_bondClass.DataBind();
                RadPanelItem item = (RadPanelItem)rpb_BondCreation.FindItemByValue("Statistics");
                RadComboBox combo = (RadComboBox)item.FindControl("cb_SAACode");
                combo.DataBind();
            }
        }
 
 
 
        protected void cb_bondClass_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            if (txt_BondType.Text == "Commercial")
                cb_Risk.DataBind();
 
            ClearSAAcode();
        }
 
 
        protected void ClearSAAcode()
        {
            RadPanelItem item = (RadPanelItem)rpb_BondCreation.FindItemByValue("Statistics");
            RadComboBox combo = (RadComboBox)item.FindControl("cb_SAACode");
            combo.Items.Clear();
            combo.DataBind();
 
            txt_SAADescription.Text = string.Empty;
            txt_SAAClass.Text = string.Empty;
            txt_RateClass.Text = string.Empty;
        }
 
        protected void cb_SAACode_DataBound(object sender, EventArgs e)
        {
            RadComboBox SAArcb = (RadComboBox)sender;
            if (SAArcb.Items.Count != 0)
            {
                SAArcb.Items.Clear();
                SAArcb.Text = string.Empty;
            }
 
            int bondType = -1;
            if (qBType == "Commercial")
                bondType = 1;
            else
                bondType = 0;
 
            List<Saa> mySAA = UtilityBond.GetSAACodeListByTypeandClass(cb_bondClass.SelectedValue, bondType);
 
            foreach (Saa s in mySAA)
            {
                RadComboBoxItem item = new RadComboBoxItem();
                item.Text = s.SAA_CODE.ToString();
                item.Value = s.SAA_DESC;
                item.Attributes.Add("GENERAL", s.GENERAL);
                item.Attributes.Add("RATECLASS", s.RATECLASS ?? "");
                item.Attributes.Add("SAACODEEFF", s.ClsCodeEff.ToString() ?? "");
                item.Attributes.Add("SAACODEDIS", s.ClsCodeDisable.ToString() ?? "");
                SAArcb.Items.Add(item);
                item.DataBind();
            }
            RadComboBoxItem item1 = new RadComboBoxItem();
            SAArcb.Items.Insert(0, item1);
        }
    }
}

Lukus
Top achievements
Rank 1
 answered on 06 Jun 2011
1 answer
95 views

I found the following code in an existing thread (http://www.telerik.com/community/forums/aspnet/editor/set-default-image-properties-when-inserting.aspx). The editor.fire executes fine, but the callback never runs. Any suggestions?

 

Telerik.Web.UI.Editor.CommandList["ImageDialog"] = function (commandName, editor, args) {
        function callBackFn(result) {
            if (result) {
               var imgTag = "<img src=" + result.imagePath + " hspace='10' vspace='5' align='right' />";
               editor.PasteHtml(imgTag);
            }
        }
        editor.fire('ImageManager' , callBackFn);
};
Dan
Top achievements
Rank 1
 answered on 06 Jun 2011
2 answers
60 views
Within the past day and a half, the radtabstrips in my project look wonky in IE8 (including compatibility mode). Here is what they look like in: Firefox and Internet Explorer 8. Until yesterday, they looked in IE like they do in Firefox, but as of last night/today they look 1px off - just wonky. I have not changed my code and in analyzing the CSS that's going on behind the scenes, the only CSS not from the Telerik code is a blanket * {margin:0; padding:0} applied to everything. This CSS entry has been in the project the whole time. I'm not doing anything particularly amazing with the control; here's the html:
<telerik:RadTabStrip runat="server" ID="rtsStatus" Width="100%" ShowBaseLine="true" AutoPostBack="true"></telerik:RadTabStrip>
and here's the code behind:
rtsStatus.DataSource = CachedDataTables.CandidateStatus
rtsStatus.DataTextField = "Title"
rtsStatus.DataValueField = "CandidateStatusID"
rtsStatus.DataBind()

This is just one sample - I use the tab control all over, sometimes with a databind, sometimes without. All of them look the same way.
Ed
Top achievements
Rank 1
 answered on 06 Jun 2011
3 answers
254 views
I have a radgrid that looks like:

<
telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="MultiEmployeeList" AutoGenerateColumns="False"
    CellSpacing="0" GridLines="None" GroupingEnabled="False" AllowMultiRowEdit="false"
    AutoGenerateEditColumn="True"  HorizontalAlign="Left"Width="800px">
    <ClientSettings>
        <ClientEvents OnCommand="OnCommand" />
    </ClientSettings>
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default">
    </HeaderContextMenu>
    <MasterTableView DataSourceID="MultiEmployeeList" DataKeyNames="rasID" ClientDataKeyNames="rasID"
        EditMode="InPlace">
        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
            <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
        <Columns>
            <telerik:GridBoundColumn DataField="empName" FilterControlAltText="Filter column column"
                UniqueName="Name" ReadOnly="true">
            </telerik:GridBoundColumn>
            <telerik:GridDropDownColumn DataField="rasRoleID" DataSourceID="RoleList" FilterControlAltText="Filter column column"
                ListTextField="mrrRoleDesc" ListValueField="mrrID" UniqueName="rasRoleID" EmptyListItemText=" -- Select Role --"
                EnableEmptyListItem="True"  >
            </telerik:GridDropDownColumn>
        </Columns>
        <EditFormSettings>
            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
            </EditColumn>
        </EditFormSettings>
    </MasterTableView>
    <FilterMenu EnableImageSprites="False">
    </FilterMenu>
</telerik:RadGrid>

I do an AJAX-type webservice post during update, and it all works fine.
My question is, how can I find the value of the combo box the user has selected during update so I can post this back using a web service?
I can get the key value of the row, but finding the new selected value (rasRoleID) is eluding me.

Thanks.
Bryan Kowalchuk
Top achievements
Rank 1
 answered on 06 Jun 2011
1 answer
51 views
I'm using a ListView which displays multiple items, I can drag'n drop each item onto a Treeview.
I'd like to drag'n drop several items at once, do you have an idea to do that?
Gimmik
Top achievements
Rank 1
 answered on 06 Jun 2011
1 answer
91 views
Hi!

From server side how can i detect if the user select all items from the "UseClientSelectColumnOnly" ?
Jayesh Goyani
Top achievements
Rank 2
 answered on 06 Jun 2011
2 answers
208 views

Are there any none issues with EditMode="PopUp" and InsertItemPageIndexAction="ShowItemOnFirstPage"

If I set EditMode="PopUp" the page index does not cahnge to the first page, or any page for that matter and newly inserted records aren't on page one.

This only seems to occur when EditMode="PopUp"

 

<MasterTableView EditMode="PopUp" Caption="Caption" CommandItemDisplay="Top"
                        NoMasterRecordsText="No Rows Returned!" DataKeyNames="ID" RetrieveNullAsDBNull="False"
                        HorizontalAlign="Center" BorderWidth="1" BorderColor="Gray" BorderStyle="Solid" 
                        InsertItemPageIndexAction="ShowItemOnFirstPage">

Roger Barnes
Top achievements
Rank 1
 answered on 06 Jun 2011
3 answers
141 views
Hi,

I have develop web application using dotnetnuke
I have rad scheduler control with two time slot context menu Item
1)New Busy Slot
2)Schedule Lesson

I have two dropdownlist, calender control on the same page also.
The expected functionaliy is open modal popup on context menu clicked.
but problem is OnTimeSlotContextMenuItemClicked event is not fired 1st time ,even it doesnt fire on calender selection changed event or dropdown selection change. I found error in mozillas erro consol screen
" Error: Sys.InvalidOperationException: A control is already associated with the element.
Source File: http://localhost:54484/dotnetnuke/ScriptResource.axd?d=PHma0e-2otry_Ysyy9H2h977jLIeN8DaDTF6ErzwLL_L9Iy1W5rT2cg3BU4MorllD3c_4X0PSAs9XJKkkZku0nl5qDgzkvAliCRsP9dmNilzj8c1cMwntVYsWHdvDmjhMhE3oBeiGlN9xjWr6ZBeJ8QnEcxU3irWPFm4JQ2&t=5c2f384e
Line: 6580"

But if click on any navigate button of scheduler control and then try to clik on context menu then it works fine.
In IE work fine.


pls do reply its very urgent


Thanks
Plamen
Telerik team
 answered on 06 Jun 2011
2 answers
97 views

I searched the entire forum and I could't find one single explanation on what happens internally to the SQL table that stores the appointments, specifically the field 'RecurranceStorage' when a 'recurring exception' occurs. Please provide me with a link that can help me to understand the magic. I want to know how recurrence series keep track of exceptions like 'moving' one instance of the series to another resource or date/time. Your sample code 'ResouceGrouping' has zero code-behind.Thanks in advance.

Dan Lehmann
Top achievements
Rank 1
 answered on 06 Jun 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Iron
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?