Telerik Forums
UI for ASP.NET AJAX Forum
3 answers
89 views

I am using rad grid to load the data in a nested view and save it into the database using a generic class (get/set the data's based on the controls in the form).
After saving the data I need to reload the data back into the radgrid in the nested view (using OnDetailTableDataBind with HierarchyLoadMode=ServerBind).

I have all the required data in the form of an xml

<Rows>
  <Row> Parent View
    <SubRow>
        Child View
    </SubRow>
   </Row>
 </Rows>

Can any one please help how to set OnDetailTableDataBind event from a generic class?

Private Function SetGridControls(ByVal telerikGrid As RadGrid, ByVal gridValue As String) As RadGrid
    Dim loXML As XmlDocument = New XmlDocument
    Dim dtRowTable As DataTable
    Dim dtColumnTable As DataTable
 
    telerikGrid.AutoGenerateColumns = True
    If gridValue.Length > 0 Then
        loXML.LoadXml(gridValue)
 
        Dim elementChild As XmlNodeList = loXML.GetElementsByTagName("SubRow")
        Dim loElem As XmlElement
        Dim loAtt As XmlAttribute
        dtRowTable = New DataTable          'Contains all the ROWS
        dtColumnTable = New DataTable       'Contains all the SUBROWS
 
        Dim blnRowDT As Boolean = False    
        Dim blnColumnDT As Boolean = False
 
        dtRowTable = New DataTable()
        dtColumnTable = New DataTable()
 
        'Loading all the subrows
        Dim SubRowList As XmlNodeList = loXML.GetElementsByTagName("SubRow")
        For Each node As XmlNode In SubRowList
            If blnColumnDT = True Then
                Exit For
            End If
            For i As Integer = 0 To node.Attributes.Count - 1
                dtColumnTable.Columns.Add(New DataColumn(node.Attributes(i).Name))
            Next
            blnColumnDT = True
        Next
 
        For Each node As XmlNode In SubRowList
            Dim row As DataRow = dtColumnTable.NewRow()
            For i As Integer = 0 To node.Attributes.Count - 1
                Dim columnName As String = node.Attributes(i).Name
                Try
                    Thread.CurrentThread.CurrentCulture = USCulture
                    If Not IsNumeric(node.Attributes(i).gridValue) AndAlso IsDate(node.Attributes(i).gridValue) Then
                        row(columnName) = DateString(CDate(node.Attributes(i).gridValue), StringFormat.ShortDate)
                    Else
                        row(columnName) = node.Attributes(i).gridValue
                    End If
                Catch e As SystemException
                    row(columnName) = node.Attributes(i).gridValue
                Finally
                    Thread.CurrentThread.CurrentCulture = CultureInfo
                End Try
            Next 
        dtColumnTable.Rows.Add(row)
        Next
 
        'Loading all the rows
        For Each loElem In loXML.DocumentElement
            If (blnRowDT = True) Then
                Exit For
            End If
            For Each loAtt In loElem.Attributes
                If Not dtRowTable.Columns.Contains(loAtt.Name) Then
                    dtRowTable.Columns.Add(New DataColumn(loAtt.Name))
                End If
            Next
            blnRowDT = True
        Next
 
 
 
        Dim iRow As Integer = 1
        For Each loElem In loXML.DocumentElement
            Dim row As DataRow = dtRowTable.NewRow()
            For Each loAtt In loElem.Attributes
                Dim columnName As String = loAtt.Name
                Try
                    Thread.CurrentThread.CurrentCulture = USCulture
                    If Not IsNumeric(loAtt.gridValue) AndAlso IsDate(loAtt.gridValue) Then
                        row(columnName) = DateString(CDate(loAtt.gridValue), StringFormat.ShortDate)
                    Else
                        If loAtt.gridValue.Trim = "" And TypeOf (row(columnName)) Is Double Then
                            row(columnName) = 0
                        Else
                            row(columnName) = loAtt.gridValue
                        End If
                    End If
                Catch e As SystemException
                    row(columnName) = loAtt.gridValue
                Finally
                    Thread.CurrentThread.CurrentCulture = CultureInfo
                End Try
            Next
            dtRowTable.Rows.Add(row)
            iRow += 1
        Next
 
        'Attaching all the rows into datasource
        telerikGrid.DataSource = dtRowTable
    End If
 
    Return telerikGrid
End Function

Maria Ilieva
Telerik team
 answered on 20 Apr 2016
0 answers
80 views

We are trying to integration spell check tool with MS CRM 2011 in Email activity. This is working fine with Web Client. But when we test the same in CCD, we are unable to select the suggested options from list of given options. But if suggested options framed have scroll bar, then we are able to pick a value. And this issue appears from second time when we load spell check for a control. Appreciate any suggestions.

 

Thanks,

Raghu

Raghu
Top achievements
Rank 1
 asked on 20 Apr 2016
5 answers
247 views

hi 

How do i remove those white border line in the header? Thanks a lot

Here are my code.

  <style>
div.RadPanelBar_Default div.rpHeaderTemplate,
div.RadPanelBar_Default a.rpLink,
div.RadPanelBar_Default a.rpSelected
{
    background-image: none;
    background-color: #2C3E50;
    color:#fff;
    border-color:#2C3E50;
    border: none 0px !important; 
    font-size:medium;

}

 div.RadPanelBar_Default .rpExpanded {
    background-color: #2C3E50 !important;
    color:#fff;
    border-color:#2C3E50;
    border: none 0px !important; 
}  

 .RadPanelBar .rpRootGroup, .rpItem .rpLink   
{    
     border: none 0px !important;    
     color: #FFF;  
     text-decoration: none;  
     border-bottom-width: 0px !important; 
     padding: 0px 0px 0px 0px !important; 
}  

.RadPanelBar rpRootGroup  .rpGroup .rpItem .rpLink
   {
      color: Green;
   }
.RadPanelBar .rpOut  
{  
    border-bottom-width: 0px !important;  
}  
.RadPanelBar_Default ul li a:link, 
.RadPanelBar_Default ul li a:visited, 
.RadPanelBar_Default ul li a:hover, 
.RadPanelBar_Default ul li a:active 
{
    color: #fff;
    display: block;
    /* width: auto !important;
    float: left; */
    border-top: 0px solid #2C3E50;
    border-bottom: 0px solid #2C3E50;
    border: none 0px !important; 
 

}
.rpExpanded {
    background-color:#2C3E50  !important;
    color:#fff;
    border: none 0px !important; 
}
 
.rpSelected {
    background-color:#2C3E50  !important;
    color:#fff;
    border: none 0px !important; 
}

 
</style>
    <telerik:RadPanelBar ID="RadPanelBar1"  runat="server">
          
    </telerik:RadPanelBar>

Ivan Danchev
Telerik team
 answered on 20 Apr 2016
0 answers
125 views

Hi, everyone,when am using asynchronous telerik upload,but when i clicks on remove it disappering upload control also,please help me..am working on this since last 2 days...

this is my telrik 

@(Html.Telerik().Upload()
        .Name("attachments_" + ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))
        .Multiple(true)
        .Async(async => async
            .Save("Save", "GalleryUser", new { name = @Model, area = "" })
                .Remove("Remove", "GalleryUser", new { name = @Model, area = "" })
            .AutoUpload(true)
        )
        .ClientEvents(events => events.OnSuccess("OnSuccess_" + ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)).OnLoad("OnLoad_" + ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)))
        .HtmlAttributes(new { @class = "gallery-upload-box" })
)

 

this is my scripts related to events

<script type="text/javascript">

    var i11 = @(i1);

    function OnSuccess_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))(e) {
        debugger;

        if (e.operation == "upload") {
            var imgUrl = "/Image?img=/" + encodeURIComponent("Content/UserFiles/Users/@Model/" + getFileInfo(e));
            var divCont = '<div class="gallery_div '+getFileInfo(e)+' gallery_div_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) gallery_img_'
                          +i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))"><img src="'+imgUrl+
                          '&w=120&h=120&t=0&c=0" alt="" /><input type="text" class="gallery_textbox"'+
                          ' id="desc_gallery_img_@(i1)_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" />'+
                          '<input type="checkbox" class="gallery_img_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" id="gallery_img_'+
                          i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" /><span for="gallery_img_'+i11+
                          '_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))">מחק</span></div>';
            //var divCont = '<div class="'+getFileInfo(e)+' gallery_div_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) gallery_img_'+i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))"><img src="'+imgUrl+'&w=120&h=120&t=0&c=0" alt="" /></div>';
            $(".gallery_editor_wrap_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))").append(divCont);
            i11 = i11 + 1;
        }
        else if (e.operation == "remove") {
            $('div[class*="'+getFileInfo(e)+'"]').remove();
           
        }
       
      
           
        }


    var PARAM_NAME = "attachments";
    function OnLoad_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))(e) {
        var uploadElement = $("input", this).attr("name", PARAM_NAME);
        setTimeout(function () {
            uploadElement.data("tUpload").name = PARAM_NAME;
        }, 0);
    }

    function getFileInfo(e) {
        return $.map(e.files, function (file) {
            var info = file.name;
            return info;
        }).join(", ");
    }
</script>
@{ Html.Telerik().ScriptRegistrar().OnDocumentReady(@<text>
        $(".gallery_img_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))").live("click", function(){
        var itemid = $(this).attr("id");
        var imgPaht = $("." + itemid + " img").attr("src");
        $.post("/GalleryUser/RemoveFile", { name: "@Model", fullName: imgPaht } )
        .success(function() {
        $("." + itemid).remove();
        });
        return false;
        });
</text>); }

<script type="text/javascript">

    var i11 = @(i1);

    function OnSuccess_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))(e) {
        debugger;

        if (e.operation == "upload") {
            var imgUrl = "/Image?img=/" + encodeURIComponent("Content/UserFiles/Users/@Model/" + getFileInfo(e));
            var divCont = '<div class="gallery_div '+getFileInfo(e)+' gallery_div_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) gallery_img_'
                          +i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))"><img src="'+imgUrl+
                          '&w=120&h=120&t=0&c=0" alt="" /><input type="text" class="gallery_textbox"'+
                          ' id="desc_gallery_img_@(i1)_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" />'+
                          '<input type="checkbox" class="gallery_img_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" id="gallery_img_'+
                          i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" /><span for="gallery_img_'+i11+
                          '_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))">מחק</span></div>';
            //var divCont = '<div class="'+getFileInfo(e)+' gallery_div_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) gallery_img_'+i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))"><img src="'+imgUrl+'&w=120&h=120&t=0&c=0" alt="" /></div>';
            $(".gallery_editor_wrap_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))").append(divCont);
            i11 = i11 + 1;
        }
        else if (e.operation == "remove") {
            $('div[class*="'+getFileInfo(e)+'"]').remove();
           
        }
       
      
           
        }


    var PARAM_NAME = "attachments";
    function OnLoad_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))(e) {
        var uploadElement = $("input", this).attr("name", PARAM_NAME);
        setTimeout(function () {
            uploadElement.data("tUpload").name = PARAM_NAME;
        }, 0);
    }

    function getFileInfo(e) {
        return $.map(e.files, function (file) {
            var info = file.name;
            return info;
        }).join(", ");
    }
</script>
@{ Html.Telerik().ScriptRegistrar().OnDocumentReady(@<text>
        $(".gallery_img_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))").live("click", function(){
        var itemid = $(this).attr("id");
        var imgPaht = $("." + itemid + " img").attr("src");
        $.post("/GalleryUser/RemoveFile", { name: "@Model", fullName: imgPaht } )
        .success(function() {
        $("." + itemid).remove();
        });
        return false;
        });
</text>); }
<script type="text/javascript">

    var i11 = @(i1);

    function OnSuccess_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))(e) {
        debugger;

        if (e.operation == "upload") {
            var imgUrl = "/Image?img=/" + encodeURIComponent("Content/UserFiles/Users/@Model/" + getFileInfo(e));
            var divCont = '<div class="gallery_div '+getFileInfo(e)+' gallery_div_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) gallery_img_'
                          +i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))"><img src="'+imgUrl+
                          '&w=120&h=120&t=0&c=0" alt="" /><input type="text" class="gallery_textbox"'+
                          ' id="desc_gallery_img_@(i1)_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" />'+
                          '<input type="checkbox" class="gallery_img_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" id="gallery_img_'+
                          i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))" /><span for="gallery_img_'+i11+
                          '_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))">מחק</span></div>';
            //var divCont = '<div class="'+getFileInfo(e)+' gallery_div_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) gallery_img_'+i11+'_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))"><img src="'+imgUrl+'&w=120&h=120&t=0&c=0" alt="" /></div>';
            $(".gallery_editor_wrap_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))").append(divCont);
            i11 = i11 + 1;
        }
        else if (e.operation == "remove") {
            $('div[class*="'+getFileInfo(e)+'"]').remove();
           
        }
       
      
           
        }


    var PARAM_NAME = "attachments";
    function OnLoad_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))(e) {
        var uploadElement = $("input", this).attr("name", PARAM_NAME);
        setTimeout(function () {
            uploadElement.data("tUpload").name = PARAM_NAME;
        }, 0);
    }

    function getFileInfo(e) {
        return $.map(e.files, function (file) {
            var info = file.name;
            return info;
        }).join(", ");
    }
</script>
@{ Html.Telerik().ScriptRegistrar().OnDocumentReady(@<text>
        $(".gallery_img_@(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty))").live("click", function(){
        var itemid = $(this).attr("id");
        var imgPaht = $("." + itemid + " img").attr("src");
        $.post("/GalleryUser/RemoveFile", { name: "@Model", fullName: imgPaht } )
        .success(function() {
        $("." + itemid).remove();
        });
        return false;
        });
</text>); }

 

these are my action methods..

 

 public ActionResult Save(IEnumerable<HttpPostedFileBase> attachments, string name)
        {
            List<int> GalleryIds = new List<int>();
            SURoleProvider pro = new SURoleProvider();
            string roles= pro.GetRolesForUser(User.Identity.Name).FirstOrDefault();
            if (!SecurityCheck(name) && roles!="Provider") throw new HttpException(401, "error");
            string UserFolder = "~/Content/UserFiles/Users/" + name + "/";
            string UserFolderPath = Server.MapPath(UserFolder);
            CreateUserFolder(UserFolderPath);
            foreach (var file in attachments)
            {
                Random n = new Random();
                var fileName = n.Next(500,10000) + Path.GetFileName(file.FileName);
                GalleryIds.Add(SaveGalleryImageTrack(UserFolder + fileName, name));
                var physicalPath = Path.Combine(UserFolderPath, fileName);
                string[] lastPart = name.Split('/');
                if (lastPart[1].ToString().Contains("CsvFile_"))
                {
                    string[] words = fileName.Split('.');
                    string ext = words[1].ToString();
                    if(ext == "csv" || ext == "vcf")
                    {
                        file.SaveAs(physicalPath);
                    }
                }
                else
                {
                    file.SaveAs(physicalPath);
                }
               
            }
            return Content("");
        }

        public ActionResult Remove(string[] fileNames, string name)
        {
           // if (!SecurityCheck(name)) throw new HttpException(401, "error");
            string UserFolder = "~/Content/UserFiles/Users/" + name + "/"; 
            string UserFolderPath = Server.MapPath(UserFolder);
            CreateUserFolder(UserFolderPath);
            foreach (var fullName in fileNames)
            {
                var fileName = Path.GetFileName(fullName);
                var physicalPath = Path.Combine(UserFolderPath, fileName);
                if (System.IO.File.Exists(physicalPath))
                {
                    System.IO.File.Delete(physicalPath);
                    RemoveFileRecordFromDB(UserFolder + fileName);
                    
                }
            }
            return Content("");
        }

anitha
Top achievements
Rank 1
 asked on 20 Apr 2016
3 answers
284 views
Some of our projects are very long, and our users would like to export just what is viewable on page web page to PDF. So, it would essentially be a narrow sliver of the entire Gantt chart, but every task (row) would be show. For example, show only a Gantt chart for the next 2 months of tasks, instead of the entire project. We thought about just pulling in a subset of tasks, but then we need to handle things like tasks that included in the next 2 months, then changing their start and end dates accordingly. However, we were hoping there was an easier way to set the start and end date of the entire Gantt chart so we can export just the time frame we are focusing on.
Ivan Danchev
Telerik team
 answered on 20 Apr 2016
2 answers
127 views

Hi

In a std combo box with check boxes as you select a few items the text value appears in the combobox text area, until its full then is says n selected.

I have a treeview in a combo box, with check boxes, how would I replicated this behaviour?

Andy

Andy Green
Top achievements
Rank 2
 answered on 20 Apr 2016
1 answer
162 views

Hey,

is it possible to get the selected keyvalue of a DataForm control as a <asp:ControlParameter...> of a SqlDataSource?

I know there a various other ways to accomplish this task, I was just wondering where i could find a property-overview or something like that :-)

 

Best regards,

Chris

Eyup
Telerik team
 answered on 20 Apr 2016
4 answers
268 views

Hi,

I have a RadTreelist with treelist select column.I have 6 rows in a RadTreelist.My requirement is to hide checkboxes in 2 rows based on a condition.How can hide checkbox in a row? and in which event is used for this purpose?I have given My code below.

 

<telerik:RadTreeList ID="RadTreeList1" runat="server" OnNeedDataSource="RadTreeList1_NeedDataSource"

 

AutoGenerateColumns="false" AllowMultiItemSelection="true"

 

AllowPaging="false" AllowSorting="true" DataKeyNames="ID"

 

ParentDataKeyNames="PID" AlternatingItemStyle-BackColor ="#EFF5FB" ItemStyle-BackColor="#E0ECF8" ShowTreeLines="true" OnItemDataBound="RadTreeList1_ItemDataBound" Width="100%">

 

<SelectedItemStyle CssClass="SelectedRow" />

 

<Columns>

 

 

<telerik:TreeListBoundColumn DataField="ID" UniqueName="ID" HeaderText="Bound Column" />

 

<telerik:TreeListSelectColumn HeaderStyle-Width="40px" >

 

</telerik:TreeListSelectColumn>
</telerik:RadTreeList >

Thanks,
Sindu.

S
Top achievements
Rank 1
 answered on 19 Apr 2016
1 answer
134 views

 

I can not get this simple required field validator column to trigger. I've followed the examples and tried various different syntax options. Can anyone shed lany light on why this isn't firing?

<telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticInserts="true" AllowPaging="true"
                        ItemType="MYCOMPANY.BusinessData.BusinessObjects.Participant"  
                        AutoGenerateColumns="False" AutoGenerateDeleteColumn="true"
                        AutoGenerateEditColumn="True" 
                        GroupPanelPosition="Top" Skin="Metro">
                        <%--<ValidationSettings EnableValidation="true" CommandsToValidate="PerformInsert" />--%>
                        <MasterTableView CommandItemDisplay="Top" AllowAutomaticInserts="true" InsertItemDisplay="Top" DataKeyNames="ParticipantID" 
                            InsertMethod="insertParticipant" DeleteMethod="deleteParticipant" UpdateMethod="updateParticipant" SelectMethod="getParticipants" 
                            PageSize="12">
                                <Columns>
                                <telerik:GridBoundColumn DataField="Username" HeaderText="Username" UniqueName="Username" ColumnEditorID="Username">
                                    <ColumnValidationSettings EnableRequiredFieldValidation="true" EnableModelErrorMessageValidation="true">
                                        <RequiredFieldValidator SetFocusOnError="true" ErrorMessage="* - Required Field" ForeColor="Red" Font-Bold="true" />
                                        <ModelErrorMessage ModelStateKey="Username" AssociatedControlID="Username" SetFocusOnError="true" ForeColor="Red"                                                   Font-Bold="true" />

                                    </ColumnValidationSettings>
                                </telerik:GridBoundColumn>

 

 

Thanks in advance!

Michael

Michael
Top achievements
Rank 1
 answered on 19 Apr 2016
4 answers
316 views

Hi,

I need to modify the filter for radgrid.

As per the requirement i have to use different filter option for different column and reduce the filter option(only contain filter) for default radgrid headercontect type of filter.

Please find the requirement and current implement of rad grid filter.

Any sample code with be greatly helpful.

Thanks.

Maria Ilieva
Telerik team
 answered on 19 Apr 2016
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?