The virtual and physical paths are not shown in the FileExplorer. I cannot see any folders when running my solution. It is designed to allow clients to select a folder path from their local filesystem. Additionally, it needs to allow users to select a folder path from a initialpath on the server. I was able to create a custom content provider for both task after reviewing and modifying code found in this link, http://www.telerik.com/support/kb/aspnet-ajax/fileexplorer/details/use-radfileexplorer-with-physical-and-shared-folder-s-paths , to no avail.
From stepping through code during debugging, I am getting the paths from the MappingFile.mapping xml file and loading them into the initialPath and viewPath properties.
' Get physical and virtual path mappings to initialize the FileExplorer upon page load. This is a helper function
' of the ConfigureFileExplorer function
Public Sub GetPhysicalVirtualPath()
Dim configFile As New XmlDocument()
Dim physicalPathToConfigFile As String = Context.Server.MapPath(Me.pathToConfigFile)
configFile.Load(physicalPathToConfigFile)
' Load the configuration file
Dim rootElement As XmlElement = configFile.DocumentElement
Dim handlerPathSection As XmlNode = rootElement.GetElementsByTagName("genericHandlerPath")(0)
' get all mappings ;
Me._itemHandlerPath = handlerPathSection.InnerText
Me.mappedPathsInConfigFile = New Dictionary(Of String, String)()
Dim mappingsSection As XmlNode = rootElement.GetElementsByTagName("Mappings")(0)
' get all mappings ;
For Each mapping As XmlNode In mappingsSection.ChildNodes
' Get the appropriately categorized path, which is the InternalShare for ReceiveInternal and SendInternal operations
Dim virtualPathAsNode As XmlNode = mapping.SelectSingleNode("VirtualPath")
Dim physicalPathAsNode As XmlNode = mapping.SelectSingleNode("PhysicalPath")
' If neither string is empty, then
If Not String.IsNullOrEmpty(virtualPathAsNode.InnerText) And Not String.IsNullOrEmpty(physicalPathAsNode.InnerText) Then
' Add all mappings to the list
Me.mappedPathsInConfigFile.Add(PathHelper.RemoveEndingSlash(virtualPathAsNode.InnerText, "/"c), PathHelper.RemoveEndingSlash(physicalPathAsNode.InnerText, "\"c))
End If
Next
End Sub
The server or client directory should be shown depending on the requested action (tab's ID) received from a hidden field on the client app. Please see the following:
Public Sub GetPhysicalVirtualPath()
Dim configFile As New XmlDocument()
Dim physicalPathToConfigFile As String = Context.Server.MapPath(Me.pathToConfigFile)
configFile.Load(physicalPathToConfigFile)
' Load the configuration file
Dim rootElement As XmlElement = configFile.DocumentElement
Dim handlerPathSection As XmlNode = rootElement.GetElementsByTagName("genericHandlerPath")(0)
' get all mappings ;
Me._itemHandlerPath = handlerPathSection.InnerText
Me.mappedPathsInConfigFile = New Dictionary(Of String, String)()
Dim mappingsSection As XmlNode = rootElement.GetElementsByTagName("Mappings")(0)
' get all mappings ;
For Each mapping As XmlNode In mappingsSection.ChildNodes
' Get the appropriately categorized path, which is the InternalShare for ReceiveInternal and SendInternal operations
Dim virtualPathAsNode As XmlNode = mapping.SelectSingleNode("VirtualPath")
Dim physicalPathAsNode As XmlNode = mapping.SelectSingleNode("PhysicalPath")
' 2/20/14 - If neither string is empty, then
If Not String.IsNullOrEmpty(virtualPathAsNode.InnerText) And Not String.IsNullOrEmpty(physicalPathAsNode.InnerText) Then
' Add all mappings to the list
Me.mappedPathsInConfigFile.Add(PathHelper.RemoveEndingSlash(virtualPathAsNode.InnerText, "/"c), PathHelper.RemoveEndingSlash(physicalPathAsNode.InnerText, "\"c))
End If
Next
End Sub
Can you clarify how the CustomFileSystemProvider.vb file should be used? I used the example provided in the link above. However, I removed the file operations (move, delete, etc.) since I only need to select folders from the directory to build a path to return to the client that will be used for processing needs. Then I added the following extended provider to the end of my page's codepage:
Public Class ExtendedFileProviderInternal
Inherits Telerik.Web.UI.Widgets.FileSystemContentProvider
'constructor must be present when overriding a base content provider class
'you can leave it empty
Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, _
ByVal selectedItemTag As String)
MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
End Sub
Public Overloads Overrides Function ResolveDirectory(ByVal path As String) As Telerik.Web.UI.Widgets.DirectoryItem
'get the directory information
Dim baseDirectory As Telerik.Web.UI.Widgets.DirectoryItem = MyBase.ResolveDirectory(path)
'remove files that we do not want to see
Dim files As New System.Collections.Generic.List(Of Telerik.Web.UI.Widgets.FileItem)()
Dim UnauthextWebConfig As String = System.Configuration.ConfigurationManager.AppSettings("UnAuthorizedFileExtensions")
Dim INVALID_EXTENSIONS As String() = FileExts()
For Each file As Telerik.Web.UI.Widgets.FileItem In baseDirectory.Files
' Get the file extension of the current file, the last element in the sequence
Dim ext As String = file.Name.Split(New Char() {"."c}).Last
' For the Internal version of the file upload control, use this code
' along with the exclusion list in the webconfig to prevent script injection from .sql, .cs, .bat, .exe., .cmd, etc.
If Not INVALID_EXTENSIONS.Contains(ext.ToLower()) Then
files.Add(file)
End If
Next
Dim newDirectory As New Telerik.Web.UI.Widgets.DirectoryItem(baseDirectory.Name, baseDirectory.Location, baseDirectory.FullPath, baseDirectory.Tag, baseDirectory.Permissions, files.ToArray(), _
baseDirectory.Directories)
'return the updated directory information
Return newDirectory
End Function
' This function gets the custom file extension exclusion list from the web.config/ApplicationSettings set by the app admins
Function FileExts() As String()
Dim extWebConfig As String = System.Configuration.ConfigurationManager.AppSettings("AllowedFileExtensions")
Dim exts As String() = extWebConfig.Split(New Char() {","c})
' If the count of extensions is not zero, then
If (exts.Count = 0) Then
exts(0) = ("undefined")
End If
' Return the array
Return exts
End Function
End Class
<formview id="test" runat="server" datasource="onesource"> |
<EditItemTemplate> |
<telerik:radpanelbar> |
<items> |
<telerik:RadPanelItem Text="1st bar" Expanded="true" > |
<Items> |
<telerik:RadPanelItem Value="clInfo" > |
<ItemTemplate> |
<asp:TextBox id="txt1st" runat="server" Text= '<%# Bind("Column1") %>' |
<ItemTemplate> |
</telerik:RadPanelItem> |
</items> |
</telerik:RadPanelItem> </items> |
</telerik:radpanelbar> |
</EditItemTemplate> |
<InsertItemTemplate> |
.... |
.... |
</InsertItemTemplate> |
</formview> |
<
telerik:RadGrid
ID
=
"AXXRadGrid"
runat
=
"server"
GridLines
=
"None"
AllowAutomaticUpdates
=
"True"
OnItemCommand
=
"AXXRadGrid_ItemCommand"
OnItemDataBound
=
"AXXRadGrid_ItemDataBound"
AutoGenerateColumns
=
"false"
OnSortCommand
=
"AXXRadGrid_SortCommand"
AllowMultiRowSelection
=
"true"
OnItemCreated
=
"AXXRadGrid_ItemCreated"
DataSourceID
=
"RequestMasterDataSource"
OnHTMLExporting
=
"AXXRadGrid_HTMLExporting"
OnExportCellFormatting
=
"AXXRadGrid_ExcelExportCellFormatting"
>
<
ExportSettings
HideStructureColumns
=
"true"
/>
<
MasterTableView
TableLayout
=
"Auto"
RetrieveDataTypeFromFirstItem
=
"true"
CommandItemDisplay
=
"Top"
>
<
CommandItemSettings
ShowExportToExcelButton
=
"false"
ShowAddNewRecordButton
=
"false"
ShowRefreshButton
=
"false"
/>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
></
Selecting
>
<
Scrolling
AllowScroll
=
"false"
></
Scrolling
>
<
Resizing
ResizeGridOnColumnResize
=
"True"
AllowRowResize
=
"True"
AllowColumnResize
=
"True"
/>
<
ClientMessages
DragToGroupOrReorder
=
"Drag to group"
/>
</
ClientSettings
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
<
table
class
=
"rgMasterTable"
border
=
"0"
id
=
"ctl00_m_g_b8cf9c0d_003b_4572_a197_c425836f7d6f_ctl00_AXXRadGrid_ctl00"
style
=
"width:100%;table-layout:auto;empty-cells:show;"
>
<
colgroup
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
<
col
style
=
"width:60px"
>
</
colgroup
>
<
thead
>
<
tr
style
=
"background-color:#EF5D63;display:none;"
>
<
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl00','')"
>SR Number</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl01','')"
>Client Name</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl02','')"
>Column 1</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl03','')"
>Column 2</
a
> <
input
type
=
"button"
name
=
"ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl04"
value
=
" "
onclick
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl04','')"
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl05','')"
>Column 3</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl06','')"
>Column 4</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl07','')"
>Column 5</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl08','')"
>Column 6</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl09','')"
>Column 7</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl10','')"
>Column 8</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl11','')"
>Column 9</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl12','')"
>Column 10</
a
></
th
><
th
scope
=
"col"
><
a
title
=
"Click here to sort"
href
=
"javascript:__doPostBack('ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl02$ctl02$ctl13','')"
>Column 11</
a
></
th
>
</
tr
>
</
thead
><
tfoot
>
<
tr
class
=
" rgPager"
>
<
td
colspan
=
"13"
><
table
summary
=
"Data pager which controls on which page is the RadGrid control."
border
=
"0"
style
=
"width:100%;border-spacing:0;"
>
<
caption
>
<
span
style
=
"display: none"
>Data pager</
span
>
</
caption
><
thead
>
<
tr
>
<
th
scope
=
"col"
></
th
>
</
tr
>
</
thead
><
tbody
>
<
tr
>
<
td
class
=
"rgPagerCell NextPrev"
><
div
class
=
"rgWrap rgArrPart1"
>
Change page: <
input
type
=
"button"
name
=
"ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl02"
value
=
" "
onclick
=
"return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl02", "", true, "", "", false, true))"
title
=
"First Page"
class
=
"rgPageFirst"
> <
input
type
=
"button"
name
=
"ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl03"
value
=
" "
onclick
=
"return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl03", "", true, "", "", false, true))"
title
=
"Previous Page"
class
=
"rgPagePrev"
><
input
type
=
"button"
name
=
"ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl04"
value
=
" "
onclick
=
"return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl04", "", true, "", "", false, true))"
title
=
"Next Page"
class
=
"rgPageNext"
> <
input
type
=
"button"
name
=
"ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl05"
value
=
" "
onclick
=
"return false;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$m$g_b8cf9c0d_003b_4572_a197_c425836f7d6f$ctl00$AXXRadGrid$ctl00$ctl03$ctl01$ctl05", "", true, "", "", false, true))"
title
=
"Last Page"
class
=
"rgPageLast"
>
</
div
><
div
class
=
"rgWrap rgInfoPart"
>
Page <
strong
>1</
strong
> of <
strong
>1</
strong
>, items <
strong
>0</
strong
> to <
strong
>0</
strong
> of <
strong
>0</
strong
>.
</
div
></
td
>
</
tr
>
</
tbody
>
</
table
></
td
>
</
tr
>
</
tfoot
><
tbody
>
<
tr
class
=
"rgNoRecords"
>
<
td
colspan
=
"13"
style
=
"text-align:left;"
><
div
>No records to display.</
div
></
td
>
</
tr
>
</
tbody
>
</
table
>
Hi,
I have implemented universal list editor, which allow me to simple edit entities by EntityDataSource. It works ok with automatic insert/update/delete functionality.
Now I'm starting new web project based on Code First EF6. So I cannot use EntityDataSource. I downloaded DatabaseDataSource from https://dbcontextdatasource.codeplex.com/
Datasource works correctly for selecting but it does not works with automatic insert/update and delete commands.
I looked to RadGrid source code and it looks that it works only with knowing datasources from .Net framework, but not with custom datasources. The insert/update/delete commands are invoked on Grid but it is not invoked to data source.
Is there some solution how to do with custom datasource or another solution how to works with automatic CUD operations with RadGrid and Code First EF6?
Thanks
Vlad