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

Hi,

 I am using radgrid version 2015 q2 template column and edit template column I want to implement duplicate record validation in insert and edit mode but I am not able to find controls in insert and edit mode of radgrid  below is my code.

If there is another easy method to validate dublicate record in radgrid plz share with me  thanks.

 

<telerik:RadGrid ID="grdLanguage" runat="server" AllowSorting="True" AllowPaging="True"
                            AllowCustomPaging="True" PagerStyle-Mode="NextPrev" Skin="Bootstrap"
                            ShowGroupPanel="false">
                            <GroupingSettings CaseSensitive="false" />
 
                            <MasterTableView AutoGenerateColumns="False" EditMode="PopUp" DataKeyNames="Language_ID" CommandItemDisplay="Top">
                                <EditFormSettings>
                                    <EditColumn FilterControlAltText="Filter EditCommandColumn1 column" UniqueName="EditCommandColumn1">
                                    </EditColumn>
                                    <PopUpSettings Modal="true" />
                                </EditFormSettings>
                                <CommandItemTemplate>
                                    <asp:LinkButton ID="LinkButton2" runat="server" CommandName="InitInsert" Visible='<%# !grdLanguage.MasterTableView.IsItemInserted %>'><img style="border:0px;vertical-align:middle;" alt="" src="Images/AddRecord.png"/>Add new</asp:LinkButton>  
                                </CommandItemTemplate>
                                <RowIndicatorColumn>
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </RowIndicatorColumn>
                                <ExpandCollapseColumn>
                                    <HeaderStyle Width="20px"></HeaderStyle>
                                </ExpandCollapseColumn>
                                <Columns>
                                    <telerik:GridTemplateColumn HeaderText="Language Name">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCertName" runat="server" Text='<%# Bind("Language_Type.Language_Type_Name") %>'></asp:Label>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Reading">
                                        <ItemTemplate>
                                            <telerik:RadRating ID="ratReading" runat="server" DbValue='<%# Bind("Read_Skill") %>' ItemCount="5" ReadOnly="true"></telerik:RadRating>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
                                    <telerik:GridTemplateColumn HeaderText="Writing">
                                        <ItemTemplate>
                                            <telerik:RadRating ID="ratWriting" runat="server" DbValue='<%# Bind("Writing_Skill") %>' ItemCount="5" ReadOnly="true"></telerik:RadRating>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
 
                                    <telerik:GridTemplateColumn HeaderText="Speaking">
                                        <ItemTemplate>
                                            <telerik:RadRating ID="ratSpeaking" runat="server" DbValue='<%# Bind("Speaking_Skill") %>' ItemCount="5" ReadOnly="true"></telerik:RadRating>
                                        </ItemTemplate>
                                    </telerik:GridTemplateColumn>
 
                                    <telerik:GridEditCommandColumn HeaderText="Edit" ButtonType="ImageButton"></telerik:GridEditCommandColumn>
                                </Columns>
                                <EditFormSettings EditFormType="Template" PopUpSettings-Height="350px" PopUpSettings-Width="600px">
                                    <FormTemplate>
 
                                        <div class="form-horizontal panel panel-primary">
                                            <div class="panel-heading">Previous Experience</div>
                                            <div class="panel-body">
                                                <div>
                                                    <asp:CustomValidator ID="CustValLanguage" OnServerValidate="CustValLanguage_ServerValidate1" ValidationGroup="valLanguage" runat="server" Display="Dynamic"> </asp:CustomValidator>
                                                </div>
                                                <div class="form-group required">
                                                    <asp:Label ID="Label1" CssClass="col-sm-2 control-label" runat="server" Text="Degree"></asp:Label>
 
                                                    <div class="col-sm-10">
                                                        <telerik:RadComboBox ID="ddlLanguage_Type_ID" SelectedValue='<%# Bind("Language_Type_ID") %>' runat="server" Skin="Bootstrap">
                                                            <Items>
                                                                <telerik:RadComboBoxItem Text="[Select Item]" Value="0" runat="server" />
                                                                <telerik:RadComboBoxItem Text="Arabic" Value="1" runat="server" />
                                                                <telerik:RadComboBoxItem Text="English" Value="2" runat="server" />
                                                                <telerik:RadComboBoxItem Text="Farsi" Value="5" runat="server" />
                                                                <telerik:RadComboBoxItem Text="French" Value="3" runat="server" />
                                                                <telerik:RadComboBoxItem Text="German" Value="4" runat="server" />
                                                            </Items>
                                                        </telerik:RadComboBox>
                                                        <br />
                                                        <span>
                                                            <asp:RequiredFieldValidator ControlToValidate="ddlLanguage_Type_ID" InitialValue="[Select Item]" Display="Dynamic" SetFocusOnError="true" CssClass="text-danger" runat="server" ID="RequiredFieldValidator5" ErrorMessage="Language is Required!"
                                                                ValidationGroup="valLanguage"></asp:RequiredFieldValidator></span>
                                                    </div>
                                                </div>
 
                                                <div class="form-group ">
                                                    <asp:Label ID="lblCertName" CssClass="col-sm-2 control-label" runat="server" Text="Reading"></asp:Label>
 
                                                    <div class="col-sm-10">
                                                        <telerik:RadRating ID="ratReading" runat="server" Precision="Item" DbValue='<%# Bind("Read_Skill") %>' ItemCount="5"></telerik:RadRating>
                                                        <span></span>
                                                    </div>
                                                </div>
                                                <div class="form-group ">
                                                    <asp:Label ID="lblCertAuthority" CssClass="col-sm-2 control-label" runat="server" Text="Writing"></asp:Label>
 
                                                    <div class="col-sm-10">
                                                        <telerik:RadRating ID="ratWriting" runat="server" Precision="Item" DbValue='<%# Bind("Writing_Skill") %>' ItemCount="5"></telerik:RadRating>
 
                                                        <span></span>
                                                    </div>
                                                </div>
                                                <div class="form-group ">
                                                    <asp:Label ID="Label2" CssClass="col-sm-2 control-label" runat="server" Text="Speacking"></asp:Label>
 
                                                    <div class="col-sm-10">
                                                        <telerik:RadRating ID="ratSpeaking" Precision="Item" runat="server" DbValue='<%# Bind("Speaking_Skill") %>' ItemCount="5"></telerik:RadRating>
                                                        <span></span>
                                                    </div>
                                                </div>
 
                                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                                    runat="server" ValidationGroup="valLanguage" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'></asp:Button
                                                <asp:Button ID="btnCancel" formnovalidate name="cancel" class="cancel" Text="Cancel" runat="server" CausesValidation="False"
                                                    CommandName="Cancel"></asp:Button>
                                            </div>
                                        </div>
 
                                    </FormTemplate>
                                </EditFormSettings>
                            </MasterTableView>
                            <ClientSettings>
                                <ClientEvents OnPopUpShowing="PopUpShowing" />
                            </ClientSettings>
                            <PagerStyle Mode="NextPrev" />
                        </telerik:RadGrid>

 

 

 ServerSide Code

 

  protected void CustValLanguage_ServerValidate1(object source, ServerValidateEventArgs args)
        {
           // Need here to validate code
 
 if (lstLanguage != null || lstLanguage.Count > 0)
            {             
                if (grdLanguage.MasterTableView.IsItemInserted)
                {
                    {
                        RadComboBox ddlLanguage_Type_ID = (RadComboBox)grdLanguage.MasterTableView.GetInsertItem().FindControl("ddlLanguage_Type_ID");
                        for (int i = 0; i < lstLanguage.Count; i++)
                        {
                            if (lstLanguage[i].Language_Type_ID == Convert.ToInt32(ddlLanguage_Type_ID.SelectedValue))
                            {
                                args.IsValid = false;
                                CustomValidator CustValLanguage = (CustomValidator)grdLanguage.MasterTableView.GetInsertItem().FindControl("CustValLanguage");
                                CustValLanguage.ErrorMessage = "Already Exists";
                            }
                        }
 
 
                    }
                }
                else
                {
                   
//                 I want code here to check update record already exist or not in the current list collection
                }
            }
        }

 

 

private List<Language> lstLanguage
        {
            get
            {
                object obj = this.Session["lstLanguage"];
                if ((!(obj == null)))
                {
                    return ((List<Language>)(obj));
                }
                List<Language> lst_Lang = new List<Language>();
                this.Session["lstLanguage"] = lst_Lang;
                return lst_Lang;
            }
            set
            {
                // Adds value to session variable
                this.Session["lstLanguage"] = value;
            }
        }

private void GrdLanguage_ItemCommand(object sender, GridCommandEventArgs e)
       {
 
           switch (e.CommandName)
           {
               case "PerformInsert":
                   if (Page.IsValid)
                   {
                       GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item.OwnerTableView.GetInsertItem();
 
                       Language obj = new Language();
                       obj.Language_ID = (int)this.lstLanguage.Count + 1;
                       obj.Language_Type_ID = Convert.ToInt32(((RadComboBox)insertedItem.FindControl("ddlLanguage_Type_ID")).SelectedValue);
                       obj.Language_Type.Language_Type_Name = ((RadComboBox)insertedItem.FindControl("ddlLanguage_Type_ID")).SelectedItem.Text;
                       obj.Read_Skill = Convert.ToInt32(((RadRating)insertedItem.FindControl("ratReading")).Value);
                       obj.Writing_Skill = Convert.ToInt32(((RadRating)insertedItem.FindControl("ratWriting")).Value);
                       obj.Speaking_Skill = Convert.ToInt32(((RadRating)insertedItem.FindControl("ratSpeaking")).Value);
 
                       lstLanguage.Add(obj);
                       grdLanguage.Rebind();
 
                   }
                   break;
               case "Update":
                   if (Page.IsValid)
                   {
                       //  GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item.OwnerTableView.GetInsertItem();
                       GridEditableItem editform = e.Item as GridEditableItem;
 
                       var index = lstLanguage.FindIndex(p => p.Language_ID == (int)editform.OwnerTableView.DataKeyValues[editform.ItemIndex]["Language_ID"]);
 
                       Language obj = new Language();
                       obj.Language_Type_ID = Convert.ToInt32(((RadComboBox)editform.FindControl("ddlLanguage_Type_ID")).SelectedValue);
                       obj.Language_Type.Language_Type_Name = ((RadComboBox)editform.FindControl("ddlLanguage_Type_ID")).SelectedItem.Text;
                       obj.Read_Skill = Convert.ToInt32(((RadRating)editform.FindControl("ratReading")).Value);
                       obj.Writing_Skill = Convert.ToInt32(((RadRating)editform.FindControl("ratWriting")).Value);
                       obj.Speaking_Skill = Convert.ToInt32(((RadRating)editform.FindControl("ratSpeaking")).Value);
 
 
                       lstLanguage[index] = obj;
                       grdLanguage.Rebind();
 
                   }
                   break;
               default:
                   break;
           }
       }
 
       private void GrdLanguage_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
       {
           grdLanguage.DataSource = lstLanguage;
       }

 

 

Kostadin
Telerik team
 answered on 07 Jan 2016
3 answers
143 views
We are trying to create a provider hosted app with a telerik radgrid which will then be hosted from a SP 2013 site.

It is known that Telerik for ASP.Net AJAX is supported in Provider Hosted App. We have include the Telerik.Web.UI dll in the bin folder of the web application. The DLL has also been added to the GAC.

The moment we try to run the app, we get no definitive details other than a generic message "An error has occurred while processing the request".

Our observation is that when we include the following tag in the web.config of the web application, "<location path="Telerik.Web.UI.WebResource.axd" />, the application crashes. 

Are we missing any step ?

Thanks in advance
Girish

Marin
Telerik team
 answered on 07 Jan 2016
13 answers
512 views
Hi, I'm having a problem with my RadGrid control when trying to sort by column
I have a simple Radgrid control which retrieves the data from an ObjectdataSource and once I pick one of the column header the following error is arised ...

Destination array is not long enough to copy all the items in the collection. Check array index and length

However, this issue is appearing when I pick two of the six columns I have in the grid, I mean, the sorting is working fine when selecting the other four columns.

Here is my source code


<telerik:RadGrid ID="RadGrid1" runat="server" AllowSorting=True DataSourceID="ODSCompaniesDataSource"
        GridLines="None" Skin="Default2006" AutoGenerateColumns="False" OnEditCommand="EditCommand" OnSortCommand="RadGrid1_SortCommand" ShowGroupPanel="True" >
<ExportSettings>
<Pdf FontType="Subset" PaperSize="Letter"></Pdf>

<Excel Format="Html"></Excel>
</ExportSettings>

<MasterTableView CommandItemDisplay="None" Frame="Border" Dir="LTR" DataSourceID="ODSCompaniesDataSource" CurrentResetPageIndexAction="SetPageIndexToFirst" TableLayout="Auto">
<EditFormSettings>
<EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"></EditColumn>
</EditFormSettings>


<ExpandCollapseColumn Visible="False" Resizable="False" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

<RowIndicatorColumn Visible="False" CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
    <HeaderStyle BackColor="#5959EE" />

    <Columns>
        <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" Visible=False DataField="company_id" HeaderText="Company Id"
            FilterListOptions="VaryByDataType" ForceExtractValue="None" UniqueName="company_id">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="company_name"
            FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Company Name"
            UniqueName="company_name">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Company_Account_Number"
            FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Account Number"
            UniqueName="Company_Account_Number">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Country_Name"
            FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Country"
            UniqueName="Country_Name">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="user_preasigned_lasc_id"
            FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Preassigned LASC"
            UniqueName="user_preasigned_lasc_id">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="region_name"
            FilterListOptions="VaryByDataType" ForceExtractValue="None" HeaderText="Region"
            UniqueName="region_name">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn CurrentFilterFunction="NoFilter" DataField="Status" FilterListOptions="VaryByDataType"
            ForceExtractValue="None" HeaderText="Status" UniqueName="Status">
        </telerik:GridBoundColumn>
        <telerik:GridEditCommandColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
            UniqueName="AutoGeneratedEditColumn" EditText="View" HeaderText="View Profile">
            <HeaderStyle Width="30px" />
        </telerik:GridEditCommandColumn>
       
       
    </Columns>
    <PagerStyle Mode="NumericPages" />
</MasterTableView>
        <GroupPanel ID="GroupPanel" Style="width: 100%;">
        </GroupPanel>
        <ClientSettings AllowDragToGroup="True">
        </ClientSettings>
</telerik:RadGrid>


Thanks in advance,

François
Kostadin
Telerik team
 answered on 07 Jan 2016
5 answers
143 views
I am using SelfHierarchySettings of master/detail grid to show parent child relation of data. The issue that I am facing is that I am not able to get the child grid if there is no child under a parent node. It just shows expanded icon and nothing else.

What I am looking for is that when I click on expand icon, it should show up a blank child grid.

Can you please provide me some code for this to achieve the above said functionality.


Thanks & Regards,
Sachin Vaid



Pavlina
Telerik team
 answered on 06 Jan 2016
1 answer
305 views

Hello.

I have gird and I add "Export to excel" to it.it Works fine.

but I want Add Summation of some Columns of it after the last row in Excel file which is not in Grid.

And second Question , Users can filter my grid and it Works fine But I want when he/she Click on "Export to Excel" button, it Exports All of Data to excel Not just Filtered. Is it Possible?

Kostadin
Telerik team
 answered on 06 Jan 2016
7 answers
304 views
Hi,

I want to add the following functionality in a RadGrid but I don't know if it can work. I have a hierarchical Grid with the following structure:

MasterTable
    Item1
           DetailTable1
    Item2
          DetailTable2
    Item3

I want to add Drag and drop row functionality only in the Detail Tables rows. I mean, reordering only rows of each Detail Table. Can I achieve this? I saw some examples only for master table. If yes can you provide me with a link example please.

Thanks
George
Jatin
Top achievements
Rank 1
 answered on 06 Jan 2016
13 answers
160 views

Hi,

 I have nested checkboxes when I select a checkbox it should select all the checkboxes below as well and same when I deselect top most checkbox. However this isn't happening. I have the following code.

 aspx:

<telerik:RadGrid ID="rgExpiringServices" OnNeedDataSource="rgExpiringServices_NeedDataSource" OnItemCommand="rgExpiringServices_ItemCommand" AllowFilteringByColumn="true" OnPreRender="rgExpiringServices_PreRender" runat="server" Skin="Black" AllowMultiRowSelection="true">
        <ClientSettings Selecting-AllowRowSelect="true" Selecting-UseClientSelectColumnOnly="true" ClientEvents-OnRowSelected="nestedGridRowSelected" ClientEvents-OnRowDeselected="nestedGridRowDeselected"></ClientSettings>
        <MasterTableView DataKeyNames="ObjectId, Name" AutoGenerateColumns="false" ShowFooter="true" HierarchyLoadMode="ServerOnDemand" EnableHierarchyExpandAll="true" AllowFilteringByColumn="true">
            <Columns>
                <telerik:GridClientSelectColumn UniqueName="BulkActionSelect" HeaderText="<%$ Resources:NrttLanguage, BulkAction %>"  ></telerik:GridClientSelectColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" ButtonCssClass="btnTiny btnApprove" UniqueName="Renew" CommandName="Renew" ImageUrl="~/Images/blank16.png" HeaderStyle-Width="16px" ItemStyle-Width="16px" ></telerik:GridButtonColumn>
                <telerik:GridButtonColumn ButtonType="ImageButton" ButtonCssClass="btnTiny btnDelete" UniqueName="Terminate" CommandName="Terminate" ImageUrl="~/Images/blank16.png" HeaderStyle-Width="16px" ItemStyle-Width="16px" ></telerik:GridButtonColumn>
                <telerik:GridNumericColumn UniqueName="Name" DataField="Name" HeaderText="<%$ Resources:NrttLanguage, CustomerReference %>" DataType="System.String"> </telerik:GridNumericColumn>
                <telerik:GridDateTimeColumn DataField="DateExpiration" DataType="System.DateTime" FilterControlAltText="Filter DateImportant column" HeaderText="<%$ Resources:NrttLanguage, DateExpiring%>" SortExpression="DateImportant" UniqueName="DateImportant" DataFormatString="{0:d}" >
                </telerik:GridDateTimeColumn>
                <telerik:GridNumericColumn UniqueName="Daysuntilexpired" DataField="DaysUntilExpiration" HeaderText="<%$ Resources:NrttLanguage, daysuntilexpired %>" > </telerik:GridNumericColumn>
                <telerik:GridBoundColumn UniqueName="Services" DataField="ServiceInReferenceString" HeaderText="<%$ Resources:NrttLanguage, Services %>" ></telerik:GridBoundColumn>
                <telerik:GridNumericColumn UniqueName="Parcelcount" DataField="RealInReference" HeaderText="<%$ Resources:NrttLanguage, ParcelCount %>" > </telerik:GridNumericColumn>
            </Columns>
            <NestedViewTemplate>
                <nrtt:CustomerGrid ID="ucExpiringRealServices" runat="server" AllowSelection="true" OnNeedDataSource="ucExpiringRealServices_NeedDataSource" OnNeedColumnCollection="ucExpiringRealServices_NeedColumnCollection" OnItemDataBound="ucExpiringRealServices_ItemDataBound" ></nrtt:CustomerGrid>
            </NestedViewTemplate>
        </MasterTableView>
    </telerik:RadGrid>

 

 

JavaScript:

function nestedGridRowSelected(sender, args) {
    var item = args.get_gridDataItem();
    var nv = item.get_nestedViews();
    if (nv !== undefined && nv !== null) {
        nv.selectAllItems();
    } else {
        //is child
        var mt = sender.get_masterTableView();
        var dtv = args.get_tableView();
        mt.selectItem(dtv.get_parentRow());
    }
}
 
function nestedGridRowDeselected(sender, args) {
    var item = args.get_gridDataItem();
    var nv = item.get_nestedViews()[0];
    if (nv !== undefined && nv !== null) {
        nv.clearSelectedItems();
    } else {
        //is child
        var mt = sender.get_masterTableView();
        var dtv = args.get_tableView();
        mt.selectItem(dtv.get_parentRow());
    }
}

When I debug it tells me that item.get_nestedViews() is undefined. Any help appreciated.

 Thanks!

 

 
Aniket
Top achievements
Rank 1
 answered on 06 Jan 2016
1 answer
76 views
Is there a way to change the textbox in the filter to a date picker?
Viktor Tachev
Telerik team
 answered on 06 Jan 2016
6 answers
231 views

Hi,

When i paste text from MS word (Times New roman, 12 pt) in to the editor, the editor is changing the font name to 'Segoe UI' for some part of the text automatically. This issue is with only some of the word documents i have. I am not able to attach the same word document with this thread as there is no option to attach word format but i have tested it on http://demos.telerik.com/aspnet-ajax/editor/examples/overview/defaultcs.aspx link and the same issue exists.

Ianko
Telerik team
 answered on 06 Jan 2016
1 answer
83 views
 Hi, I just want to change text for "Day,Week,Month" buttons, please someone help me out.
Bozhidar
Telerik team
 answered on 06 Jan 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?