Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
119 views
Okay so here is the problem.  I have a self-referencing grid that is setup for drag and drop.  It takes a row and it can move it up and down and it can make it a child of another row.  everything is working fine 99% of the time.  Where I run into the issue is when I close the drop down menus that show the children and then try to move a row in the grid.  Here's my code:

<script type="text/javascript">
    function gridRowDropping(sender, args) {
        var targetTable = args.get_targetItemTableView();
        if (!targetTable || targetTable.get_owner().get_id() !== sender.get_id()) {
            args.set_cancel(true);
        }
    }
</script>
 
<div id="DropUnderWrapper">
    <asp:CheckBox ID="IsUnder" runat="server" Text=" Drop Under Parent" />
</div>
<telerik:RadGrid ID="SiteMenuGrid" runat="server"
    AutoGenerateColumns="false" AllowMultiRowSelection="false"
    OnNeedDataSource="SiteMenuGrid_NeedDataSource"
    OnItemCreated="SiteMenuGrid_ItemCreated"
    OnRowDrop="SiteMenuGrid_RowDrop">
    <MasterTableView DataKeyNames="MenuID, ParentID, SortOrder" CommandItemDisplay="Top" CommandItemSettings-AddNewRecordText="Add Menu Item" HierarchyDefaultExpanded="true" HierarchyLoadMode="Client" Width="100%">
        <Columns>
            <telerik:GridDragDropColumn UniqueName="DragDropColumn" HeaderStyle-Width="20px"/>
            <telerik:GridBoundColumn DataField="MenuText" HeaderText="Name" UniqueName="Name" />
            <Telerik:GridHyperLinkColumn DataNavigateUrlFields="SitePageID" DataNavigateUrlFormatString="/admin/pageManager/?CID={0}" DataTextField="PageTitle" HeaderText="Page Title" UniqueName="PageTitle"  />
            <telerik:GridBoundColumn DataField="MenuUrl" HeaderText="Url" UniqueName="MenuUrl" />
            <telerik:GridBoundColumn DataField="MenuTarget" HeaderText="Target" UniqueName="MenuTarget" />
            <telerik:GridBoundColumn DataField="IsEnabled" HeaderText="Status" UniqueName="MenuItemEnabled" />
            <telerik:GridEditCommandColumn ButtonType="ImageButton" HeaderStyle-Width="20px" />
            <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow" ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" HeaderStyle-Width="20px" />
        </Columns>
        <EditFormSettings UserControlName="~/includes/userControls/MenuForm.ascx" EditFormType="WebUserControl">
            <EditColumn UniqueName="MenuForm">
            </EditColumn>
        </EditFormSettings>
        <SelfHierarchySettings KeyName="MenuID" ParentKeyName="ParentID" />
    </MasterTableView>
    <ClientSettings AllowRowsDragDrop="true">
        <Selecting AllowRowSelect="true" />
        <ClientEvents OnRowDropping="gridRowDropping" />
    </ClientSettings>
</telerik:RadGrid>

here's my code behind:

private string[] MenuID = { "MenuID", "ParentID", "SortOrder" };
private List<SiteMenu> MenuList = new List<SiteMenu>();
 
protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    SiteMenuGrid.Skin = "Default";
    SiteMenuGrid.AutoGenerateColumns = false;
    SiteMenuGrid.NeedDataSource += SiteMenuGrid_NeedDataSource;
    SiteMenuGrid.InsertCommand += SiteMenuGrid_InsertCommand;
    SiteMenuGrid.UpdateCommand += SiteMenuGrid_UpdateCommand;
    SiteMenuGrid.DeleteCommand += SiteMenuGrid_DeleteCommand;
    SiteMenuGrid.ItemDataBound += SiteMenuGrid_ItemDataBound;
    SiteMenuGrid.MasterTableView.CommandItemDisplay = GridCommandItemDisplay.Top;
    SiteMenuGrid.MasterTableView.CommandItemSettings.ShowRefreshButton = false;
    SiteMenuGrid.ClientSettings.AllowRowsDragDrop = true;
    SiteMenuGrid.ClientSettings.Selecting.AllowRowSelect = true;
    SiteMenuGrid.ClientSettings.ClientEvents.OnRowDropping = "gridRowDropping";
 
    MenuList = new SiteMenu().SelectAllPublicMenuItemsBySiteIDNotDeleted(PCSSession.Current.SiteID);
}
 
protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);
    if (!IsPostBack)
    {
        SiteMenuGrid.MasterTableView.FilterExpression = "ParentID = 0";
    }
}
 
protected void SiteMenuGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
{
    SiteMenuGrid.DataSource = MenuList;
}
 
protected void SiteMenuGrid_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridNoRecordsItem && e.Item.OwnerTableView != e.Item.OwnerTableView.OwnerGrid.MasterTableView)
    {
        e.Item.OwnerTableView.ParentItem.Expanded = false;
        e.Item.OwnerTableView.ParentItem["ExpandColumn"].Controls[0].Visible = false;
    }
    if (e.Item is GridCommandItem && e.Item.OwnerTableView != SiteMenuGrid.MasterTableView)
    {
        e.Item.Style["display"] = "none";
    }
}
 
protected void SiteMenuGrid_ItemDataBound(object sender, GridItemEventArgs e)
{

}
 
protected void SiteMenuGrid_InsertCommand(object sender, GridCommandEventArgs e)
{

}
 
protected void SiteMenuGrid_UpdateCommand(object sender, GridCommandEventArgs e)
{
}
 
protected void SiteMenuGrid_DeleteCommand(object sender, GridCommandEventArgs e)
{

}
 
protected void SiteMenuGrid_RowDrop(object sender, GridDragDropEventArgs e)
{
    int key = (int)e.DraggedItems[0].GetDataKeyValue("MenuID");
 
    int destinationId = 0;
    int sortOrder = 0;
 
    if (IsUnder.Checked)
    {
        destinationId = (int)e.DestDataItem.GetDataKeyValue("MenuID");
        sortOrder = 1;
    }
    else
    {
        destinationId = (int)e.DestDataItem.GetDataKeyValue("ParentID");
        sortOrder = ((int)e.DestDataItem.GetDataKeyValue("SortOrder")) + 1;
    }
 
    if (destinationId == 0)
    {
        if (key != destinationId)
        {
            MenuList.FirstOrDefault(i => i.MenuID == key).ParentID = destinationId;
            MenuList.FirstOrDefault(i => i.MenuID == key).SortOrder = sortOrder;
 
            foreach (SiteMenu menuItem in MenuList.Where(i => i.ParentID == destinationId))
            {
                if (menuItem.SortOrder >= sortOrder && menuItem.MenuID != key)
                {
                    menuItem.SortOrder += 1;
                }
            }
 
            if (new SiteMenu().UpdateMenuListByParentID(destinationId, MenuList.Where(i => i.ParentID == destinationId).ToList()))
            {
                Response.Redirect("/admin/menuManager/");
            }
        }
    }
    else
    {
        if (key != destinationId && key != MenuList.FirstOrDefault(i => i.MenuID == destinationId).ParentID)
        {
            MenuList.FirstOrDefault(i => i.MenuID == key).ParentID = destinationId;
            MenuList.FirstOrDefault(i => i.MenuID == key).SortOrder = sortOrder;
 
            foreach (SiteMenu menuItem in MenuList.Where(i => i.ParentID == destinationId))
            {
                if (menuItem.SortOrder >= sortOrder && menuItem.MenuID != key)
                {
                    menuItem.SortOrder += 1;
                }
            }
 
            if (new SiteMenu().UpdateMenuListByParentID(destinationId, MenuList.Where(i => i.ParentID == destinationId).ToList()))
            {
                Response.Redirect("/admin/menuManager/");
            }
        }
    }
}
Kevin
Top achievements
Rank 1
 answered on 24 Sep 2012
1 answer
53 views
Hi,

Referring to the link http://www.ximnet.com.my/upload/br_tag_removed_automatically.swf. Browser is IE (9, 10)



1. It is a list.

2. I try to use Shift-Enter to create a line break in one of the item.

3. The line break is removed by editor.

4. I try to put in BR manually and it is removed as well.



Is there a way to stop the BR tag from being removed?



Thanks.

Misho
Telerik team
 answered on 24 Sep 2012
2 answers
73 views
Hi there,

in a HTML table there is two row.
in first row, Calling a new page(.ascx) in which RadMenu Defined.
in Second row, ribbonBar Defined.

Now issue is, 
RadMenu horizontal Drop down popping up underneath of RibbonBar.

this issue persisting with IE7 only.
Kate
Telerik team
 answered on 24 Sep 2012
1 answer
44 views
Is there a way to select a cell (column and row) and position the view to that cell on page load?

I have done row positioning before, but never column.

Thanks,

Terry
Galin
Telerik team
 answered on 24 Sep 2012
1 answer
56 views
Good morning! I'm using Raddock to show some customer information. But I have some problems with the appearance of Raddock, specifically in Internet Explorer just below the title bar. I am attaching a picture with the problem.Thank you!
Bozhidar
Telerik team
 answered on 24 Sep 2012
9 answers
528 views
Hello,

I have a Hierarchical RadGrid with 3 Detail tables nested inside. I'd like to know if it's possible to hide the tables if they have no records instead of showing them with the "No child records to display." message?

Note: I do not want to do this: http://www.telerik.com/help/aspnet-ajax/grdhideexpandcollapseimageswhennorecords.html. I just need to hide tables that might have no records, but one will always have records.

Thanks!
Caleb
Top achievements
Rank 1
 answered on 24 Sep 2012
1 answer
94 views
Hi  ,

My code is below.

  protected void rgDocumentType_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
 {
   TextBox tbFilter=null;
                AjaxControlToolkit.FilteredTextBoxExtender ftExtender;
                if (e.Item is GridFilteringItem)
                {
                    GridFilteringItem fItem = (GridFilteringItem)e.Item;
                    foreach (GridColumn col in rgDocumentType.MasterTableView.Columns)
                    {
                        
                    
                        if (Convert.ToString(col.UniqueName).Equals("colIsModified") == false && Convert.ToString(col.UniqueName).Equals("colActive") == false && Convert.ToString(col.UniqueName).Equals("colCONCUR_ID") == false && Convert.ToString(col.UniqueName).Equals("colRemark") == false)
                        {
                            
                              tbFilter  = fItem[col.UniqueName].Controls[0] as TextBox;
                              tbFilter.ID = col.UniqueName;
                              ftExtender = new AjaxControlToolkit.FilteredTextBoxExtender();
                               ftExtender.TargetControlID = tbFilter.ID;
                               ftExtender.FilterMode = AjaxControlToolkit.FilterModes.InvalidChars;
                               ftExtender.FilterType=AjaxControlToolkit.FilterTypes.Custom|AjaxControlToolkit.FilterTypes.Numbers|AjaxControlToolkit.FilterTypes.LowercaseLetters | AjaxControlToolkit.FilterTypes.UppercaseLetters;
                               ftExtender.InvalidChars = @"%!&;`'\|*?~<>^()[]{}$&quot;";
                               tbFilter.Controls.Add(ftExtender);

                               col.CurrentFilterFunction = GridKnownFunction.Contains;
                               col.AutoPostBackOnFilter = true;

                              
                              
                               ftExtender = null;
                               tbFilter = null;
                            

                                                      
                        }
                       
                    }
                } 


}

This code is used for blocking some special characters in the filter textbox Also prevent pasting.
I set the current filter function here But when clicking on the filter menu button it does not work?

Thanks & Regards
Anzar.M
Eyup
Telerik team
 answered on 24 Sep 2012
3 answers
165 views
Hi,

I have to set current filter function at run time and when i click on the filter button it take the currently setted filter function.

Thanks & Regards
Anzar.M
Eyup
Telerik team
 answered on 24 Sep 2012
1 answer
106 views
Hi there,

I have a kendo grid which binds into  a datatable (it has to bind into a datatable as I do not know which columns i am expecting)
It seems like when binding a grid to a datatable, date columns are not being recognized as dates, and rendered as strings. So no filtering, sorting or formatting, and the date is being displayed in the json string format: /Date(1348489271318)/

The mark up is as follows:
    @{ Html.Kendo().Grid(Model.GridModel)
        .Name("Grid")
        .Columns(columns =>
        {
            foreach (System.Data.DataColumn column in Model.GridModel.Columns)
            {              
                var c = columns.Bound(column.DataType, column.ColumnName).Title(column.Caption);
             
                 if (column.ColumnName == "DateAdded")
                {                   
                    c.Format("{0:dd/MM/yyyy hh:mm}");
                 }
            }
        })

Once I change the datasource into a class model, then everything works fine, the dates are rendered as dates with the correct format, filtering and sorting.

Any ideas why column of datatype date is getting rendered as a string?
Thanks
N
Jayesh Goyani
Top achievements
Rank 2
 answered on 24 Sep 2012
2 answers
108 views

Hi 

I have an asp drop down list with a list of years 12/13 11/12 10/11,

I want to know how if a user picks 11/12 it changes the year of the radscheduler to the year 2011. 

so far on page load it just gives you the current day,month and year.


cheers

John M


John
Top achievements
Rank 1
 answered on 24 Sep 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Bronze
Iron
Iron
yw
Top achievements
Rank 2
Iron
Iron
Stefan
Top achievements
Rank 2
Iron
Iron
Iron
Kao Hung
Top achievements
Rank 1
Iron
Bohdan
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?