Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
83 views

I've got a grid that I need to sort by a column that refers to a related entity. I need to figure out the syntax to do this.

 

Details:

<telerik:GridTemplateColumn UniqueName="AGNUM" DataField="AGNUM" HeaderText="Agent" AllowSorting="True" SortExpression="PAgents.AGNAME">
    <EditItemTemplate>
        <telerik:RadComboBox ID="rcb_Agent_Edit" DataSourceID="Entity_Agents_Active"
            AppendDataBoundItems="true" DropDownWidth="400px"
            SelectedValue='<%# Bind("AGNUM") %>' runat="server" DataValueField="AGNUM" DataTextField="AGNAME">
            <Items>
                <telerik:RadComboBoxItem Text="" Value="99999" />
            </Items>
        </telerik:RadComboBox>
    </EditItemTemplate>
    <ItemTemplate>
        <%# DataBinder.Eval(Container.DataItem, "PAgents.AGNAME") %> <-- Same string works fine here, though.
    </ItemTemplate>
</telerik:GridTemplateColumn>

The above throws an argument exception: Input string was not in a correct format.Couldn't store in PAgents.AGNAME Column. Expected type is Int32.

The grid is bound to an entity data source (defined below)

The two relevant data sources:

<asp:EntityDataSource ID="Entity_AgLicensing" runat="server" ConnectionString="name=dev_SuretyDBEntities" ContextTypeName="BSGSuretyRewrite.Entities.DataAccess.LinqToEntities.dev_SuretyDBEntities"
    DefaultContainerName="dev_SuretyDBEntities" EnableFlattening="false" EntitySetName="AgLicense" Include="AgLicenseStatus,PAgents" EnableDelete="true" EnableInsert="true" EnableUpdate="true"
    Where="it.[PNUMBER]=@PNUMBER && it.[AGNUM] IS NOT NULL"
    OnInserting="Entity_AgLicensing_Inserting" OnDeleted="Entity_AgLicensing_Deleted" OnUpdating="Entity_AgLicensing_Updating">
    <WhereParameters>
        <asp:ControlParameter ControlID="hfPnumber" Name="PNUMBER" PropertyName="Value" DbType="Int32" />
    </WhereParameters>
</asp:EntityDataSource>
<asp:EntityDataSource ID="Entity_AgLicensing_Agency" runat="server" ConnectionString="name=dev_SuretyDBEntities" ContextTypeName="BSGSuretyRewrite.Entities.DataAccess.LinqToEntities.dev_SuretyDBEntities"
    DefaultContainerName="dev_SuretyDBEntities" EnableFlattening="false" EntitySetName="AgLicense" Include="AgLicenseStatus" EnableDelete="true" EnableInsert="true" EnableUpdate="true"
    Where="it.[PNUMBER]=@PNUMBER && it.[AGNUM] IS NULL" OnInserting="Entity_AgLicensing_Agency_Inserting" OnDeleted="Entity_AgLicensing_Agency_Deleted">
    <WhereParameters>
        <asp:ControlParameter ControlID="hfPnumber" Name="PNUMBER" PropertyName="Value" DbType="Int32" />
    </WhereParameters>
</asp:EntityDataSource>

 

 

 

Eyup
Telerik team
 answered on 31 Oct 2017
3 answers
112 views

I am having a problem with grouping on a grid. I have two select fields, one which shows the current group, and one which shows a count of rows.

The header text works fine on the first group, but all subsequent groups, it looks like it is just showing a template of the text.

The attached image shows the way it is coming out. I collapsed the first group so all the group headers could be seen together.

You can see that the first group shows up fine showing "Pass: ; Fields: 73". This is correct, as that first group, all of the rows have the value for the PASS field empty.

But then the subsequent two groups are wrong. Taking the second group as example, it SHOULD show "Pass: 6; Fields 1", but instead it shows "  Fields: {0}".

The below is the code for the groupbyexpressions for the grid in question.

01.<groupbyexpressions>
02.    <telerik:gridgroupbyexpression>
03.        <groupbyfields>
04.            <telerik:gridgroupbyfield fieldname="PASSNUMBER" />
05.        </groupbyfields>
06.        <selectfields>
07.            <telerik:gridgroupbyfield fieldname="PASSNUMBER" headertext="Pass" fieldalias="PASS" />
08.            <telerik:gridgroupbyfield fieldname="ROWID" headertext="Fields" fieldalias="FIELDS" aggregate="Count" />
09.        </selectfields>
10.    </telerik:gridgroupbyexpression>
11.</groupbyexpressions>
Eyup
Telerik team
 answered on 31 Oct 2017
4 answers
249 views
I'm having problems finding a control in my grid.  I've been stuck on this for a couple of days and have searched the forums, following examples and links to documentation, with no luck.  Here's a snippet from the aspx page.

 <telerik:GridTemplateColumn UniqueName="ddHeader" HeaderText="Header"
   <EditItemTemplate> 
     <asp:DropDownList ID="HeaderDropDown" runat="server" /> 
   </EditItemTemplate> 
 </telerik:GridTemplateColumn> 

And here's a snippet from code behind.
private void Grid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridEditableItem) 
        { 
            GridEditableItem item = e.Item as GridEditableItem; 
            Dictionary<string, string> dict = new Dictionary<string, string>(); 
            dict = ReadHeader(); 
            DropDownList list =item.FindControl("HeaderDropDown") as DropDownList; 
            list.DataSource = dict
            list.DataBind(); 
        } 
    } 

DropDownList list =item.FindControl("HeaderDropDown") as DropDownList;  always returns null.

What am I not getting here?

Thanks,







JazzBox
Top achievements
Rank 1
 answered on 30 Oct 2017
0 answers
163 views

I've seen a ton of questions on this, however no simple explanations why this is occurring or what the solution to the problem is.

We've got a Batch Edit Update Grid that I originally had a RadComboBox in that was working fine until I found that keyboard navigation was screwing up the keyboard flow and saw that it was recommended to switch to a RadDropDown control, so I did, which is in a GridTemplateColumn similar to this:

<telerik:RadGrid ID="RadGrdActionInputs" runat="server" Width="900px"  OnNeedDataSource="RadGrdActionGroupInputs_NeedDataSource"
AutoGenerateColumns="False" RenderMode="Lightweight" AllowSorting="True"
OnItemDataBound="RadGrdActionInputs_ItemDataBound"
oninsertcommand="RadGrdActionInputs_InsertCommand"
onupdatecommand="RadGrdActionInputs_UpdateCommand"
ondeletecommand="RadGrdActionInputs_DeleteCommand"
oneditcommand="RadGrdActionInputs_EditCommand"
AutoGenerateEditColumn="True" >
<GroupingSettings CollapseAllTooltip="Collapse all groups"></GroupingSettings>
 
<MasterTableView CommandItemDisplay="TopAndBottom" DataKeyNames="ID" EditMode="Batch">
<BatchEditingSettings EditType="Row" />
<CommandItemSettings ShowCancelChangesButton="true" ShowRefreshButton="false" />
 
....
 
<telerik:GridTemplateColumn HeaderText="Data Point" DataField="DataPointID" HeaderStyle-Width="500px">
    <ItemTemplate>
        <telerik:RadTextBox ID="RadTextBox1" runat="server" Width="150px"></telerik:RadTextBox>
    </ItemTemplate>
    <EditItemTemplate>
        <telerik:RadDropDownList RenderMode="Lightweight" ID="ddDataPointList" runat="server" Width="300px">
        </telerik:RadDropDownList>
    </EditItemTemplate>
    <HeaderStyle Width="500px"></HeaderStyle>
</telerik:GridTemplateColumn>

 

In the examples and the problems/posts that I have seen, they all recommend checking the e.item type in the ItemDataBound event.  If the e.item is a GridDataItem then bind a label, else if it's a GridEditableItem bind the dropdown, IE:

protected void RadGrdActionInputs_ItemDataBound(object sender, GridItemEventArgs e)
{
    //get combobox data for drop down.
    DataPointsModel dataPointsModel = ConfigurationController.GetAllDataPoints();
     
    try {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
 
            RadLabel lblActionGroupType = item.FindControl("lblDataPoint") as RadLabel;
 
            //get value for ActionGroupTypeID
            string val = DataBinder.Eval(item.DataItem, "DataPointID").ToString();
 
            
        }
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            RadDropDownList rddl = item.FindControl("ddDataPointList2") as RadDropDownList;
            BindRadDropDownDataList("I", rddl, "Name", "ID");
        }
    }
    catch {}
}

 

Problem is, this code never gets called:

if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        {
            GridEditableItem item = e.Item as GridEditableItem;
            RadDropDownList rddl = item.FindControl("ddDataPointList2") as RadDropDownList;
            BindRadDropDownDataList("I", rddl, "Name", "ID");
        }

 

I'm pulling my hair out on this one..

 

 

JazzBox
Top achievements
Rank 1
 asked on 30 Oct 2017
0 answers
98 views

Given the following object structure...

    public class CategoryViewModel
    {
            public int category_id {get; set;}

            public string category_name {get; set;}
            public List<CategoryDetailsViewModel> details { get; set; }
    }

    public class CategoryDetailsViewModel
    {
        public string category_detail_id {get; set;}

        public string category_admin {get; set;}
    }

 

Is it possible to use a DetailTable where the details are defined in the parent object? For example, I've tried this, though all the detail tables were empty:

    <telerik:RadGrid runat="server" ID="rgCategories" OnNeedDataSource="rgCategories_NeedDataSource" Skin="Silk" AutoGenerateColumns="false">
        <MasterTableView>
            <DetailTables>
                <telerik:GridTableView Name="Category Details">
                    <Columns>
                        <telerik:GridBoundColumn HeaderText="Category Admin" DataTextField="details.category_admin"></telerik:GridBoundColumn>
                    </Columns>
                </telerik:GridTableView>
            </DetailTables>
            <Columns>
                <telerik:GridBoundColumn HeaderText="Category" DataField="category_name"></telerik:GridBoundColumn>
            </Columns>
        </MasterTableView>
    </telerik:RadGrid>

Tyler
Top achievements
Rank 1
 asked on 30 Oct 2017
1 answer
50 views
I have been trying to create a custom sort on a grid on my front end application and the compare function is never called.  I tried running the sample code here to see if I had missed something but that doesn't work either.  Can anyone offer a solution please?  I have tried this in IE11 and the latest version of Chrome with the same result.
David
Top achievements
Rank 1
 answered on 30 Oct 2017
1 answer
214 views
I have this RadComboBox (ddlSrvTypCde) that triggers the radajaxmanager but I don't want the controls on the last <tr></tr> to get affected. I tried putting PostBackControls but it doesn't work.

//
        function centerLoadingPanel(ajaxManager, eventArgs) {
            centerElementOnScreen($get("<%= AjaxLoadingPanel.ClientID %>"));
        }


//


<telerik:RadAjaxManager ID="RadAjaxManager" PostBackControls="txtAFPCde, txtAFPCdeName, ButtonDialogAFPCde, btnAFPCde, txtAFPCdeVal, txtAFPCdeNameVal, txtAFPCdeId" runat="server">
<ClientEvents OnRequestStart="centerLoadingPanel"></ClientEvents>
</telerik:RadAjaxManager>


<asp:Panel ID="pnlAllowed" runat="server" Visible="true">

<telerik:RadAjaxLoadingPanel ID="AjaxLoadingPanel" PostBackControls="txtAFPCde, txtAFPCdeName, ButtonDialogAFPCde, btnAFPCde, txtAFPCdeVal, txtAFPCdeNameVal, txtAFPCdeId" runat="server" />
<asp:Panel ID="AjaxUpdateStub" runat="server">

<telerik:RadMultiPage runat="server" ID="multiService" SelectedIndex="0" SkinID="RadMultiPageModalForm" Height="315px">
<telerik:RadPageView runat="server" ID="pgeType">
<div class="FormTabSpacer">
<table class="FormHeaderInnerTable">
<tr>
<td>
<table style="width: 500px">
<tr>
<td style="text-align: right; width: 140px;">
<asp:Label ID="lblServiceType" runat="server" Text="Service Type" "></asp:Label>
</td>
<td style="text-align: left; width: 320px;">
<telerik:RadComboBox ID="ddlSrvTypCde" runat="server" Width="317px" TabIndex="3" AutoPostBack="true" CausesValidation="false">
</telerik:RadComboBox>

</td>
</tr>
<tr>
<td class="FormColumnCellLeft">&nbsp;
</td>
<td class="FormColumnCellRight">
<asp:CheckBox ID="chkAllowFractions" runat="server" TabIndex="4" Text="Service"  Style="display: none" />
</td>
</tr>

<tr>
<td class="FormColumnCellLeft">&nbsp;
</td>
<td class="FormColumnCellRight">
<asp:CheckBox ID="chkUseTier" runat="server" Text="Tiered Pricing" TabIndex="6" />
</td>
</tr>

<tr>
<td class="FormColumnCellLeft">&nbsp;
<asp:Label ID="lblAFPCde" runat="server" Text="AFP Code" ></asp:Label>&nbsp;
</td>
<td class="FormColumnCellRight">
<asp:TextBox ID="txtAFPCde" runat="server" Width="50px" ReadOnly="True" SkinID="disabledtextbox"></asp:TextBox>
<asp:TextBox ID="txtAFPCdeName" runat="server" ReadOnly="True" SkinID="disabledtextbox" Width="193px" TabIndex="999"></asp:TextBox>
<input id="ButtonDialogAFPCde" runat="server" name="ButtonDialogAFPCde" style="width: 20px;" type="button" value="..." tabindex="8" />
<asp:Button ID="btnAFPCde" runat="server" SkinID="pickupbutton" Visible="False" TabIndex="999" />
<asp:TextBox ID="txtAFPCdeVal" runat="server" Width="70px" TabIndex="999"></asp:TextBox>
<asp:TextBox ID="txtAFPCdeNameVal" runat="server" Width="220px" TabIndex="999"></asp:TextBox>
<asp:TextBox ID="txtAFPCdeId" runat="server" Width="70px" TabIndex="999"></asp:TextBox>

</td>
</tr>
Vessy
Telerik team
 answered on 30 Oct 2017
1 answer
71 views
I am writing a page that uses a RadEditor for an administrator to create text files.  The other users need to read these files.  Is there a Telerik control that displays rich text or should I make the RadEditor readonly and hide the RadButton? 
Rumen
Telerik team
 answered on 30 Oct 2017
6 answers
745 views

 

 Does anyone know of a way to easily prevent double clicking the next button. e.g. I dont want to charge the user's credit card twice.

 

Any help would be great. Thanks!

Ivan Danchev
Telerik team
 answered on 30 Oct 2017
1 answer
91 views

I have a situation where users need to edit previously entered data, which might not be valid.  For example, assume the valid range for an invoice date is the current month (10/1/2017 to 10/31/2017).  Also assume I have an existing invoice with a date outside that range (11/5/2017).  I'd like to present the invalid value to the user, and have the min/max validation force them to fix it. 

Ideally, I could just set the min, max, and selected values in the code behind, and let the client side validation do it's job.  However, setting the selected date to the invalid date in the code behind throws an exception.  I also tried setting the selected date first, then applying the min/max...but then it changes the selected date based on the min/max.  And the InvalidTextBoxValue is read only, so that's not an option.

 

Is there a way to have the initial date value be an invalid value?  I used the example of a date being outside the min/max range...but in our situation it's possible that the original value wouldn't even be a valid date.  Is there anything built into the control that would help with this situation?  One option would be to not use the built in min/max...and implement my own client side validation to do the range check.  But I view that as a last resort.

 

 

Eyup
Telerik team
 answered on 30 Oct 2017
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
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
Bronze
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?