Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
92 views
I am very new at this so, sorry if this is very basic.

I got a rad grid for all my employees and am trying to have a Race, Sex and Classification drop down box to populate the data.

Is there a way to do that right in the editor?

Do I just replace my bound fields with the dropdownboxes and enter the list of available choices somewhere? 

I can not seem to find a way to do this?

Thanks
Matt
Eyup
Telerik team
 answered on 10 Jul 2012
1 answer
93 views
Hello all ,

i've nested radgrid : Radgrid2 into radgrid1

and i want to get the selected row id when "onRowClick" event fires ,

i wrote this js function :   

 function RowClick(sender, eventArgs) {
        var grid = sender;
        var MasterTable = grid.get_masterTableView();
        var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
        var cell = MasterTable.getCellByColumnUniqueName(row, "Forum_id");
        alert(cell.innerHTML);
    }
 

the client side code is :
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
            <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true"  OnItemCommand="RadGrid1_ItemCommand" >           
                    <MasterTableView>
                    <NestedViewTemplate>
                        <telerik:RadGrid ID="RadGrid2" runat="server" AllowPaging="True" OnNeedDataSource="RadGrid2_NeedDataSource">                                 
                               <ClientSettings>
                
        <ClientEvents OnRowClick="RowClick"/>
    </ClientSettings>
                       </telerik:RadGrid>
      
                    </NestedViewTemplate>                    
                </MasterTableView>
                <ClientSettings>     
        <ClientEvents OnRowClick="RowClick"/>
    </ClientSettings>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>

when i click on a row of radgrid1 , js function works rightly .
but when i click on a row of radgrid2 , 2 alert messages appear : the first one gives me the right selected id (what i want ) but the other one gives me the the selected index ..  

how to prevent "onRowClick" event to fire 2 times when i click on radgrid2??  
Tsvetoslav
Telerik team
 answered on 10 Jul 2012
1 answer
99 views
Hi,

I have a RadGrid Control on my WebPage with an editable column.
After edit this column and postback the request, inside the CSharp event

protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
    {
// rg is the RadGrid       
        if (rg != null)
        {
            if (e.Argument == string.Empty)
            {
                rg.Rebind();
            }

            string[] editedItemIds = e.Argument.Split(':');
            int i;
            for (i = 0; i <= editedItemIds.Length - 2; i++)
            {
                try
                {
                    Guid itemId = Guid.Parse(editedItemIds[i]);

//This is the row that give the problem

                    GridDataItem updatedItem = rg.MasterTableView.FindItemByKeyValue("ArticoloId", itemId);
                   
                    UpdateValues(itemId, updatedItem);
                }
                catch
                {
                }
            }
            rg.Rebind();
        }
    }


As told before the rg.MasterTableView.Items collection is empty and so the method "FindItemByKeyValue" does not never return any value.
I follow your example at
http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/clienteditbatchupdates/defaultcs.aspx

Your help will be much appreciated.
Thanks in advance.

Tsvetoslav
Telerik team
 answered on 10 Jul 2012
3 answers
325 views
Hi, i have been using the RadScheduler for a few Days. I want to Display Data from my Database in the Calendar.

My Table looks like that:

RoomName
Description
From-Date
Until-Date

I want to display these Data in the Calendar. I added a SqlDataSource and established an Connection to my Database. I tested the Query and it works. 

My Question is, how can i use this Data to Display the different Appointments in the Calendar. I only want to display them. No new Insert or Update.


Thanks in advcance
Vijaianand
Top achievements
Rank 1
 answered on 09 Jul 2012
2 answers
179 views
I've been searching through the documentation to do a simple server-side select and access the data in that row. I found this page here (http://www.telerik.com/help/aspnet-ajax/grid-retrieve-primary-key-field-values-for-items.html) and used a line from the sample code:

RadGrid1.SelectedItems[0].GetDataKeyValue("CustomerID").ToString()

Visual Studio gives me an error of "'Telerik.Web.UI.GridItem' does not contain a definition for 'GetDataKeyValue' and no extension method 'GetDataKeyValue' accepting a first argument of type 'Telerik.Web.UI.GridItem' could be found (are you missing a using directive or an assembly reference?)"

I tried a different route using this:

grd.SelectedItems[0].Cells[1].Text

but this doesn't return anything at runtime, regardless of the index I use for the cells collection.

Please advise. Thanks guys!

Darren
Top achievements
Rank 2
 answered on 09 Jul 2012
2 answers
147 views
The project got a RadSlider, a RadNumericTextBox and a Label. Changing values ​​RadSlider the value shown in RadNumericTextBox, Label displays the function result (deposit + interest).

The problem is that I can not create an event that would change the values ​​in RadNumericTexBox (change clients) value delegated to RadSlider.

<script type="text/javascript">
        function ManualValueChange(sender, eventArgs) {
            $get("CalcSlider").value = sender.get_newValue();
        }
    </script>
    <telerik:RadAjaxManager ID="PpAjaxManager" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="CalcSlider">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="CalcSliderDeposit" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="lblYouHave" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="lblprofit" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="CalcSliderDeposit">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="CalcSlider" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="lblYouHave" UpdatePanelRenderMode="Inline" />
                    <telerik:AjaxUpdatedControl ControlID="lblprofit" UpdatePanelRenderMode="Inline" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
   <div class="typeCalc">
                    <br />
                    <table style="width: 640px; margin: 0 auto;">
                        <tr>
                            <td colspan="2" style="height: 20px; text-align: center">
                                <h3>
                                    BondMarketers Invest Plan</h3>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 80px; border-top: 1px solid gray; text-align: center">
                                <telerik:RadSlider ID="CalcSlider" runat="server" Skin="Black" MinimumValue="0" MaximumValue="10000"
                                    LargeChange="2000" SmallChange="10" Width="650px" Height="65px" ItemType="Tick"
                                    TrackPosition="TopLeft" AnimationDuration="600" ShowDragHandle="false" OnValueChanged="CalcSliderValueChanged"
                                    AutoPostBack="true">
                                </telerik:RadSlider>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 20px">
                                  
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 200px; text-align: center">
                                Invest:
                            </td>
                            <td>
                                <telerik:RadNumericTextBox runat="server" ID="CalcSliderDeposit" Type="Currency"
                                    Culture="en-US" DataType="System.Decimal" AutoPostBack="true">
                                    <ClientEvents OnValueChanged="ManualValueChange" OnLoad="ManualValueChange" />
                                </telerik:RadNumericTextBox>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 20px">
                                  
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 200px; text-align: center">
                                <asp:Label runat="server" ID="lblYouHave" />
                            </td>
                            <td>
                                <asp:Label runat="server" ID="lblprofit" Font-Bold="True" Font-Size="Larger" ForeColor="Green" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="height: 20px">
                                  
                            </td>
                        </tr>
                    </table>
                </div>


Method to change the values​​:

protected void CalcSliderValueChanged(object sender, EventArgs e)
       {
           double percent = FormulaLayer.FormulaValue((decimal)CalcSlider.Value);
           decimal deposit = (decimal)CalcSlider.Value;
           int percents = 100;
 
           DateTime sDate = DateTime.Now;
           DateTime eDate = DateTime.Now.AddDays(365);
 
           CalcSliderDeposit.Value = Convert.ToDouble(deposit);
            
                
           lblYouHave.Text = "You have: ";
 
           lblprofit.Text = string.Format("${0}", ((Convert.ToDouble(deposit) / percents) * percent * Convert.ToDouble(FormulaLayer.GetWorkDayCount(sDate, eDate)) + Convert.ToDouble(CalcSlider.Value)));
       }


Thanks for any help.

Sorry for my bad english... :D
Patrik
Top achievements
Rank 2
 answered on 09 Jul 2012
1 answer
304 views
What I am trying to do is uncheck another checkbox in the same row. I want to have a subscribe and unsubscribe checkbox columns. So when you click on subscribe the unsubscribe checkbox should uncheck and vise versa. I found a lot of entries that are similar in the forums but didnt come across anything in this. Found something in the old ASP forum but its not working. Below is what I ahve.

Source
<telerik:RadGrid ID="grdPubList" runat="server" Skin="Office2007" GridLines="None"
                                               AutoGenerateColumns="False" AllowNaturalSort="false" CellSpacing="0">
                                               <HeaderStyle Width="100px" HorizontalAlign="Center" />
                                               <ClientSettings>
                                                   <Selecting CellSelectionMode="None"></Selecting>
                                               </ClientSettings>
                                               <MasterTableView AllowMultiColumnSorting="true" ShowHeadersWhenNoRecords="false">
                                                   <NoRecordsTemplate />
                                                   <CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
                                                   <RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
                                                   </RowIndicatorColumn>
                                                   <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
                                                   </ExpandCollapseColumn>
                                                   <Columns>
                                                       <telerik:GridTemplateColumn ItemStyle-Width="250px" HeaderStyle-Width="250px" ItemStyle-HorizontalAlign="Left"
                                                           ItemStyle-VerticalAlign="Top" HeaderText="Publication Name">
                                                           <ItemTemplate>
                                                               <asp:Label ID="lblPubId" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.PubID").ToString() %>'
                                                                   CssClass="label_default_nb" Visible="false"></asp:Label>
                                                               <asp:Label ID="lblPubName" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Name").ToString() %>'
                                                                   CssClass="label_default_nb"></asp:Label>
                                                           </ItemTemplate>
                                                           <HeaderStyle Width="250px"></HeaderStyle>
                                                           <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="250px"></ItemStyle>
                                                       </telerik:GridTemplateColumn>
                                                       <%--<telerik:GridBoundColumn HeaderText="Practice Area" DataField="departmentDescription"
                                                           AllowSorting="false" ItemStyle-HorizontalAlign="Left" ItemStyle-VerticalAlign="Top"
                                                           ItemStyle-Width="100px" HeaderStyle-Width="50px">
                                                           <HeaderStyle Width="50px"></HeaderStyle>
                                                           <ItemStyle HorizontalAlign="Left" VerticalAlign="Top" Width="100px"></ItemStyle>
                                                       </telerik:GridBoundColumn>--%>
                                                       <%--<telerik:GridTemplateColumn ItemStyle-HorizontalAlign="Center" ItemStyle-Wrap="False"
                                                           ItemStyle-VerticalAlign="Top" HeaderText="Modified <br> By/Date" UniqueName="ModifiedByDate"
                                                           ItemStyle-Width="100px" HeaderStyle-Width="100px">
                                                           <ItemTemplate>
                                                               <asp:Label ID="lblUserModified" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.userModified").ToString() %>'
                                                                   CssClass="label_default_nb" Width="100px"></asp:Label>
                                                               <asp:Label ID="lblDateModified" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.dateModifiedStr").ToString() %>'
                                                                   CssClass="label_default_nb" Width="100px"></asp:Label>
                                                           </ItemTemplate>
                                                       </telerik:GridTemplateColumn>--%>
                                                       <telerik:GridTemplateColumn FilterControlAltText="Filter TemplateColumn1 column"
                                                           HeaderText="Format" UniqueName="typeDescription" DataField="typeDescription">
                                                           <ItemTemplate>
                                                               <asp:Label ID="lblPubType" runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.typeDescription").ToString() %>'
                                                                   CssClass="label_default_nb"></asp:Label>
                                                           </ItemTemplate>
                                                       </telerik:GridTemplateColumn>
                                                       <telerik:GridTemplateColumn HeaderText="Subscribe">
                                                           <ItemTemplate>
                                                               <asp:CheckBox ID="radchkSubscribe" runat="server" />
                                                           </ItemTemplate>
                                                       </telerik:GridTemplateColumn>
                                                       <telerik:GridTemplateColumn HeaderText="Unsubscribe">
                                                           <ItemTemplate>
                                                               <asp:CheckBox ID="radchkUnsubscribe" runat="server" />
                                                           </ItemTemplate>
                                                       </telerik:GridTemplateColumn>
                                                   </Columns>
                                                   <EditFormSettings>
                                                       <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                                                       </EditColumn>
                                                   </EditFormSettings>
                                               </MasterTableView>
                                               <FilterMenu EnableImageSprites="False">
                                               </FilterMenu>
                                           </telerik:RadGrid>


VB code in the page. 
Private Sub grdPubList_ItemCreated(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles grdPubList.ItemCreated
      If TypeOf e.Item Is GridDataItem Then
          Dim item As GridDataItem = DirectCast(e.Item, GridDataItem)
          Dim chk1 As CheckBox = DirectCast(item.FindControl("radchkSubscribe"), CheckBox)
          Dim chk2 As CheckBox = DirectCast(item.FindControl("radchkUnsubscribe"), CheckBox)
          'Dim chk3 As CheckBox = DirectCast(item.FindControl("CheckBox3"), CheckBox)
          chk1.Attributes.Add("onclick", (("checkUncheck('" + chk1.ClientID & "','") + chk2.ClientID & "',')"))
           
      End If
  End Sub


Javascript in masterpage. Though i think the ch2.checked should be false in the if and true in the else.
<script type="text/javascript">
       function checkUncheck(c1, c2) {
           var ch1 = document.getElementById(c1);
           var ch2 = document.getElementById(c2);
 
           if (ch1.checked) {
               ch2.checked = true;
 
           }
           else {
               ch2.checked = false;
 
           }
       }    
   </script>

Casey
Top achievements
Rank 1
 answered on 09 Jul 2012
1 answer
133 views
I have a switch statement in a javascript function that performs different actions based on the type of control that is being passed, however the sender.type of the RadComboBox is null. How do I get the type?

here is my javascript function:

function RefreshCsiOptions(sender) {
            switch (sender.type) {
                case "radio":
                    if (sender.checked == true) {
                        for (i = 0; i < cbxCSI.length; i++) {
                            var z = rcbCSI[i];
                            if (rcbCSI[i].get_selecteditem().get_value() != "") { rcbCSI[i].disabled = "disabled"; } else { cbxCSI[i].disabled = true; }
                            cbxCSI[i].checked = false;
                        }
                        lblWithoutCSI.disabled = "";
                    }
                    break;
                case "checkbox":
                    var cbxNumber = sender.id.substr(6, 1);
                    if (sender.checked == true) {
                        rcbCSI[cbxNumber - 1].disabled = "";
                        lblWithoutCSI.disabled = "disabled";
                        rbWITHOUT.checked = false;
                    } else {
                        rcbCSI[cbxNumber - 1].disabled = "disabled";
                    }
                    CheckWithoutStatus();
                    break;
                case "select-one":
                    var rcbNumber = sender.id.substr(14, 1);
                    if (rcbNumber == "_") rcbNumber = "0";
                    var rcbValue = rcbCSI[rcbNumber].get_selecteditem().get_value();
                    document.Form1.elements['CSI' + rcbNumber + '_value'].value = rcbValue;
                    if (rcbValue != "") {
                        cbxCSI[rcbNumber].disabled = false;
                        cbxCSI[rcbNumber].checked = true;
                        if (rbWITHOUT.checked == true) rbWITHOUT.checked = false;
                    } else {
                        cbxCSI[rcbNumber].disabled = true;
                        cbxCSI[rcbNumber].checked = false;
                        CheckWithoutStatus();
                    }
                    break;
                default:
                    //alert(sender.type);
                    break;
            }
        }  
Nencho
Telerik team
 answered on 09 Jul 2012
6 answers
161 views
Hi! There is a radscheduler whose datasource is a list of appointments, each of them having one or more resources. (There is many-to-many relationship between appointments and resources). Also, there is a checkboxlist of resources, used for binding resurce type of a scheduler. How can I group scheduler by that resource type, to look like in your example on http://demos.telerik.com/ASPNET/Prometheus/Scheduler/Examples/ResourceGrouping/DefaultCS.aspx? (I would like it to have as many columns as number of boxes cheked in checkboxlist). As I understod, relationsheep should be one-to-many or I have to set some appointmentProviders in webconfig?

This is what a have:

<

telerik:RadScheduler runat="server" ID="RadScheduler1" Skin="<%$ AppSettings: SchedulerSkin%>"Width="750px" StartEditingInAdvancedForm="false" SelectedView="MonthView" DataKeyField="ID"DataSubjectField="Subject" DataStartField="Start" DataEndField="End" DataRecurrenceField="RecurrenceRule"DataRecurrenceParentKeyField="RecurrenceParentID" EnableEmbeddedSkins="true" OverflowBehavior="Expand">
<ResourceTypes><telerik:ResourceType TextField="Naziv" KeyField="ResursID" Name="Resurs"/>
</ResourceTypes></telerik:RadScheduler>



I bind scheduler in code behind, and I want to do that with the resource type to, as simplier as it can be. Please help. Thanks,
Ana
Plamen
Telerik team
 answered on 09 Jul 2012
1 answer
105 views
Hi,

I need your help to the following problem. I have a RadGrid which displays some records. Each record can be edit using PopUp Edit Form which is of type WebUserControl (see sample code below)

<telerik:RadGrid ID="grid" runat="server" OnItemCreated="grid_ItemCreated" OnEditCommand="grid_EditCommand"
AutoGenerateColumns="False"  OnNeedDataSource="grid_NeedDataSource"  >
<MasterTableView DataKeyNames="Id" EditMode="PopUp" EnableViewState="true">
    <Columns>
        ...
    </Columns>
    <EditFormSettings UserControlName="~/MyControl.ascx" EditFormType="WebUserControl"  PopUpSettings-Modal="true">
    </EditFormSettings>
</MasterTableView>
</telerik:RadGrid>

On Edit command I want to pass the selected grid row values into the userControl(MyControl.ascx ) using the setter methods exist on the userControl. My problem is how can I get an instance of the userControl inside the grid_EditCommand in order to set the values.

Thanks
Pan
Elliott
Top achievements
Rank 2
 answered on 09 Jul 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?