Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
123 views
Hi,
I have website where people are able to drag and drop custom WebUserControl on a Radgrid. I'm using jQuery-ui to do that but the problem is when i have too much row on my grid, the draggable animation is slow and the control is not moving with the cursor. He teleports to the cursor when we stop moving.

Is there a way to set the Grid's cells "droppable" on the server-side ?

The css class "drag" is on each WebUserControl.
The css class "drop2" is on the <ItemStyle> markup for each columns except the first column.

Javascript :
jQuery.noConflict();
                 
                function pageLoad(sender, args) {
                    jQuery(document).ready(function ($) {
 
                        var title;
                        var col, row, preCol, preRow;
 
                        // set the element draggable (WebUserControl)
                        $(".drag").draggable({
                            drag: function (event, ui) {
                                title = this.title;
                            }
                        });
 
                        // set the element droppable (each cells of RadGrid but not on the first column
                        $(".drop2").droppable({
                            drop: function (event, ui) {
                                col = $(this).parent().children().index($(this));
                                row = $(this).parent().parent().children().index($(this).parent());
                                dropped();
                                alert('Ligne: ' + row + ', Colonne: ' + col);
                            }
                        });
 
                        // AjaxRequest with cell indexes and control's id <== title property
                        function dropped() {
                            $find('<%= RadAjaxManager1.ClientID%>').ajaxRequest("Drop;" + title + ";" + col + ";" + row);
                        }
                    });
                }
 

Code-behind :
public partial class WebForm2 : System.Web.UI.Page
    {       
        protected void Page_Load(object sender, EventArgs e)
        {          
            // Create a List of half day for the next 3 months
            List<string> Montableau = new List<string>();
            DateTime monHeure = DateTime.Now.AddDays(-1).AddHours(-DateTime.Now.Hour).AddMinutes(-DateTime.Now.Minute).AddSeconds(-DateTime.Now.Second).AddMilliseconds(-DateTime.Now.Millisecond);
            while (monHeure < DateTime.Now.AddMonths(3))
            {
                Montableau.Add(monHeure.ToShortDateString() + " " + monHeure.ToShortTimeString());
                monHeure = monHeure.AddHours(12);
            }
 
            RadGrid1.DataSource = Montableau;
            RadGrid1.DataBind();
 
            for (int i = 0; i < Montableau.Count; i++)
            {
                RadGrid1.Items[i].Cells[2].Text = Montableau[i];
                RadGrid1.Items[i].Cells[3].Text = "";
                RadGrid1.Items[i].Cells[4].Text = "";
                RadGrid1.Items[i].Cells[5].Text = "";
            }
 
            // Creating 2 WebUserControl dynamically
            WebUserControl1 ctrl = (WebUserControl1)LoadControl("~/WebUserControl1.ascx");
            ctrl.idControl = "wuc9";
            ctrl.ID = "wuc9";
            ctrl.numeroAffaire = "9";
            ctrl.leSite = "Test";
            ctrl.idControl = ctrl.ID;
            ctrl.couleurFond = Color.Aqua;
            Panel2.Controls.Add(ctrl);
 
            WebUserControl1 ctrl2 = (WebUserControl1)LoadControl("~/WebUserControl1.ascx");
            ctrl2.idControl = "wuc10";
            ctrl2.ID = "wuc10";
            ctrl2.numeroAffaire = "10";
            ctrl2.leSite = "Test";
            ctrl2.idControl = ctrl2.ID;
            ctrl2.couleurFond = Color.Lime;
            Panel2.Controls.Add(ctrl2);
        }           
 
        protected void RadAjaxManager1_AjaxRequest(object sender, Telerik.Web.UI.AjaxRequestEventArgs e)
        {
            if (e.Argument.StartsWith("Drop"))
            {
                string[] mesArg = e.Argument.Split(';');
                 
                // Search the control with the id (title attributes)
                WebUserControl1 user = this.FindControl(mesArg[1]) as WebUserControl1;
 
                // Search the RadGrid
                RadGrid rg = (RadGrid)FindControl("RadGrid1");
                if (rg != null)
                {
                    // Add control in the correct cell
                    if (rg.Items[int.Parse(mesArg[3])].Cells[int.Parse(mesArg[2]) + 2].Controls.Count == 0)
                    {
                        rg.Items[int.Parse(mesArg[3])].Cells[int.Parse(mesArg[2]) + 2].Controls.Add(user);                       
                    }
                    else
                    {
                        RadAjaxManager1.Alert("Cette case contient deja un control");
                    }
                }
                UpdatePanel1.Update();
            }
        }
    }

Thanks !
samuel
Top achievements
Rank 1
 answered on 08 Jul 2013
1 answer
137 views
I am looking to use the filter control as a tool to let my clients easily generate there own SQL where conditions.  Please realize though that I am using this control alone and do not have/want it tied to a grid or any other control. However I have some conditions that at the moment doesn't seem to work to well with the control.  

1) I already store in a SQL table all the Fields and Operators a client can select upon.  However the radFilter does not appear to let you define the operators for a specific field on the server side.  So for example I would be adding all my fields on PageLoad or PreInit and maybe I don't want a specific field like "Last Name" to have "IsNull" as a filter option but another field may allow it.
* Doing this only in the client side like all suggestions seem to direct you is really a hack and leads to unclean code especially when your not blanket-ally removing an operator across all fields.

2) I would like to make my own field but am wondering if the filter control can handle it.  Say for example someone wanted to query for "Transaction Amount" > 100 and "Transaction Date" between 1/1/2012 and 3/3/2012.  To handle this properly you would have to make a unique operator(s) that would let you set the fields shown.  You may also want to do something like "Transaction Amount" between 100 and 1000 and "Transaction Date" between 1/1/2012 and 3/3/2012.  Then there would be possibility of 4 values and 2 operator conditions.
* Please realize that what I am saying is different then 2 different filter items.  Because I am specifically saying i want to find people with a transaction amount greater then 100 between the specific dates.  If you used what the Sqlprovider gives you actually end up with people who have some transaction > 100 unrelated to the provided supplied date range.  I realize that this requires parsing on my part and wouldn't rely on the SqlProvider for anything.

3) There appears to be no built in method to get a simple representation of the filters other then radFilter.RootGroup.Expressions but you have to parse all the fields out yourself?
* Has telerik given any thought to a XmlProvider so that you can get a representation of the filter fields, operators, and values as XML?  This would allow others to take that XML and interpret it how they choose.

4) Similar to number 3 the Save/Load functionality should support an xml string versus base64 encoded string.  This would allow you to interpret the xml how you choose and possibly review created selects directly in sql.
Antonio Stoilkov
Telerik team
 answered on 08 Jul 2013
1 answer
178 views
Hi guys.I am creating tree view from some of my class object dynamically.
What i need to do is drag(just drag not remove) the leaf node into the rich text editor text.



I have tried to create the nodetemplate but not succcessful( other wise just add the node template in the leaf node with label)
Following is the code of making the treeview node.

TreeView1.Nodes.Clear();

            DocumentTemaplateCompiledDto obj = DocumentTemaplateCompiledBll.GetInstance.GetDocumentTemaplateCompiledByTemplateId(Int32.Parse(ddlTemplates.SelectedValue));


if (obj.LstSections != null && obj.LstSections.Count > 0)
            {
                foreach (var objSection in obj.LstSections)
                {
                    var tNode = new RadTreeNode(objSection.SectionName);                  
 
                    if (obj.LstSimpleFields != null && obj.LstSimpleFields.Any(h => h.FkDocumentTemplateSectionId == objSection.DocumentTemplateSectionId))
                    {
                        var tNodeChildSimpleFields = new RadTreeNode("Simple_fields_Control");
 
                        foreach (var objSimplefield in obj.LstSimpleFields.FindAll(h => h.FkDocumentTemplateSectionId == objSection.DocumentTemplateSectionId))
                        {
                            var tNodeChildGridTextEntry = new RadTreeNode(objSimplefield.FieldName);
                            tNodeChildGridTextEntry.Nodes.Add(new RadTreeNode
                            {
                                Text = objSimplefield.FieldCode,//these are the leaf node
                                AllowEdit = true,//this I have done as a last possible option
                                AllowDrop = true,//this I have done as a last possible option
                                AllowDrag = true//this I have done as a last possible option
                            });
                            tNodeChildSimpleFields.Nodes.Add(tNodeChildGridTextEntry);
                        }
                        tNode.Nodes.Add(tNodeChildSimpleFields);
                    }
                    TreeView1.Nodes.Add(tNode);
                }
            }
             
            


<telerik:RadEditor ContentAreaMode="Div" runat="server" ID="RadEditor1" Height="515"
            Width="700" Visible="True">
            </telerik:RadEditor>


Please suggest me how can i achieve my desired reuslt.
Any help guys?
kamii47
Top achievements
Rank 1
 answered on 08 Jul 2013
1 answer
177 views
Hi,

can anyone please help, I am in the process of converting one of our working basic repeaters into a RadListView.

On the OnItemDataBound event I want to fire some code to format items in the itemtemplate using one of our business objects "tblVehicle" with the following code:
protected void uiRptCars_ItemDataBound(object sender, Telerik.Web.UI.RadListViewItemEventArgs e)
    {
        if (e.Item is Telerik.Web.UI.RadListViewDataItem)
        {
            tblVehicle item = ((tblVehicle)e.Item).DataItem;
            string name = string.Format("{0} {1} {2}", item.RegDate.Year, item.Make, item.Model);
            string url = string.Format("{0} {1} {2}", item.Make, item.Model, item.RegDate.Year).ToLower().Replace(" ", "-").Replace("/", "~");
            Image uiImgCar = (Image)e.Item.FindControl("uiImgCar");
            Literal uiLitTitle = (Literal)e.Item.FindControl("uiLitTitle");
            Literal uiLitColour = (Literal)e.Item.FindControl("uiLitColour");
            Literal uiLitFuel = (Literal)e.Item.FindControl("uiLitFuel");
            Literal uiLitTrans = (Literal)e.Item.FindControl("uiLitTrans");
            Literal uiLitEng = (Literal)e.Item.FindControl("uiLitEng");
            uiLitTitle.Text = string.Format("<h3><a href='/cars-for-breaking/{0}/{1}'>{2}</a></h3>", item.VehicleId, url, name);
            uiLitColour.Text = item.Colour;
            uiLitFuel.Text = item.FuelType;
            uiLitTrans.Text = item.Transmission;
            uiLitEng.Text = item.EngineCode;
            uiImgCar.AlternateText = name;
}
}

However, at the line

tblVehicle item = ((tblVehicle)e.Item).DataItem;
I'm getting the following error: Cannot convert type 'Telerik.Web.UI.RadListViewItem' to 'tblVehicle'
I'm sure there is a simple answer to this as everything worked fine under a straightforward repeater control.
Any help would be greatly appreciated.

Regards
Dale


Marin
Telerik team
 answered on 08 Jul 2013
6 answers
220 views
Hello Everyone,

i want to create one drop-down menu like shown in image on all row of RadGrid where i can click on individual link to perform task like edit,delete etc,


can anyone have idea about this?

Thanks
Viktor Tachev
Telerik team
 answered on 08 Jul 2013
1 answer
60 views
I have a grid that works great.

When I edit it I fill a combo box with data.  Everything works great until I change EditMode to InPlace.  When I do that the combo box has the DataTextField in its SelectedValue field.

Here is how I load the data into the RadComboBox.

ddlSecurityRole.DataSource = ocRoles
ddlSecurityRole.DataTextField = "Description"
ddlSecurityRole.DataValueField = "ID"
ddlSecurityRole.DataBind()

When I read the data I do this.
O.ID_SecurityRole = CLng(DirectCast(objEI("SecurityRole").Controls(0), RadComboBox).SelectedValue)

If I have EditMode="InPlace" in my MasterTableView tag then the .SelectedValue equals the Description instead of the ID.

If I remove EditMode="InPlace" then .SelectedValue equals the ID.
Jayesh Goyani
Top achievements
Rank 2
 answered on 08 Jul 2013
2 answers
184 views
i want to Display  InvalidStyle and ErrorMessage inside RadInput,but only display style, the errorMessage not display
code like this

<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <div>
        <telerik:RadTextBox ID="txtAppId" runat="server" Width="300" AutoPostBack="false">
        </telerik:RadTextBox>
        <asp:RequiredFieldValidator ID="TextBoxRequiredFieldValidator" runat="server" Display="None"
            ControlToValidate="txtAppId" Text="*" ErrorMessage="NOT NULL">                          
        </asp:RequiredFieldValidator>
    </div>
    </form>
</body>
</html>
<script type="text/javascript">
    function ValidatorUpdateDisplay(val) {
        //debugger
        if (typeof (val.display) == "string") {
            if (val.display == "None") {
                ValidatorUpdateDisplayEnd(val);
                return;
            }
            if (val.display == "Dynamic") {
                val.style.display = val.isvalid ? "none" : "inline";
                return;
            }
        }
        if ((navigator.userAgent.indexOf("Mac") > -1) &&
        (navigator.userAgent.indexOf("MSIE") > -1)) {
            val.style.display = "inline";
        }
        val.style.visibility = val.isvalid ? "hidden" : "visible";
    }
 
    function ValidatorUpdateDisplayEnd(args) {
        //debugger
        var textbox = $find(args.controltovalidate);
        if (textbox) {
            if (args.isvalid) {
                textbox._invalid = false;
                textbox.updateCssClass();
            }
            else {
                textbox.set_textBoxValue("NOT NULL");
                textbox._invalid = true;
                textbox.updateCssClass();
            }
        }
    }
</script>

parlardin
Top achievements
Rank 1
 answered on 08 Jul 2013
1 answer
308 views
Hi, 

In RadAutoCompleteBox, when we add tokens, each one has a button to remove it from the list.
The tooltip for the button has text 'remove token'.
 Is it possible to change the text on the tooltip for this button to something other than 'remove token'.

I've seen a similar question for changing the remove icon image but not sure how to go about it for tooltip.

Thanks
Laurence
Top achievements
Rank 1
 answered on 07 Jul 2013
3 answers
102 views
Hi,

        I used the textbox in edit template for update the values in gridview. But I got the problem(Collection was modified; enumeration operation may not execute.) .Please give me the solution.

My Code behind code:

 protected void RadGrid1_UpdateCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridDataItem id = (e.Item as GridDataItem);
            string Empid = id.OwnerTableView.DataKeyValues[id.ItemIndex]["EmpId"].ToString();
            foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
            {
                TextBox txtleavetaken = (TextBox)item.FindControl("txttakenleave");
                TextBox txtleaveremain = (TextBox)item.FindControl("txtleavecount");
                TextBox txttotalworkdays = (TextBox)item.FindControl("txttotalworkdays");
                TextBox txtadvance = (TextBox)item.FindControl("txtadvance");
                TextBox txtbonus = (TextBox)item.FindControl("txtbonus");
                TextBox txtothers = (TextBox)item.FindControl("txtothers");
                TextBox txttotalsalary = (TextBox)item.FindControl("txttotalsalary");
                objpl.empname = Empid.ToString();
                objpl.takenleave = txtleavetaken.Text;
                objpl.leave = txtleaveremain.Text;
                objpl.totalworkdays = txttotalworkdays.Text;
                objpl.empadvance = txtadvance.Text;
                objpl.bonus = txtbonus.Text;
                objpl.empothers = txtothers.Text;
                objpl.totalsalary = txttotalsalary.Text;
                objbl.updatesalarydetail(objpl);
                fullviewstaff();
            }



Thanks,
Arun.
Jayesh Goyani
Top achievements
Rank 2
 answered on 06 Jul 2013
1 answer
78 views
Hello,

How to add legend in Pie chart dynamically.

like diff. data with diff. label
Ajay
Top achievements
Rank 1
 answered on 06 Jul 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?