Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
234 views
I would like to create the diagram that
  • User can drag & drop the item (Image) into the diagram.
  • User can create the connection to link each item.
  • User can save the diagram into JSON.
  • User can load the diagram from JSON

Now, I can archive the first, second and third requirements. However, I have the problem when I try to load data from JSON. The Images are missing, and the connections also lost. I try to solve the problem by using 'visualTemplate' by setting '<ShapeDefaultsSettings Visual="visualTemplate" />', but it breaks my diagram instead. I have attached my code below.

This is my drag & drop event
function setDropTargetOnDiagram(element) {
     $telerik.$(element).kendoDropTarget({
          drop: function (e) {
               var draggable = e.draggable,
                    element = e.dropTarget,
                    diagram = element.getKendoDiagram();
 
               if (draggable && draggable.hint) {
                    var item = draggable.hint.data("data"),
                         offset = draggable.hintOffset,
                         point = new kendo.dataviz.diagram.Point(offset.left, offset.top),
                         transformed = diagram.documentToModel(point);
 
               item.id += "_" + generateUUID();
               item.x = transformed.x;
               item.y = transformed.y;
 
               var shape = createCustomShape(item);                               
             diagram.addShape(shape);
               }
          }
     });
}
 
function createCustomShape(item) {
     var shape = new kendo.dataviz.diagram.Shape(item);
     var image = new kendo.dataviz.diagram.Image({
          source: "../Images/Diagram/" + item.content.ImageName,
          x: 0,
          y: 0,
          width: item.width,
          height: item.height,
          stroke: {
               width: 0
          }
     });
     var textBlock = new kendo.dataviz.diagram.TextBlock({
          text: item.content.CustomText,
               color: "#000",
               fontSize: 12,
               x: item.content.TextX,
               y: item.content.TextY
     });
 
     shape.visual.append(image);
     shape.visual.append(textBlock);
 
     return shape;
}

This is my dragItem
<div class="dragItem" data-data='{"id": "StartProcess", "content": {"CustomText":"Start", "TextX":"18", "TextY":"70", "ImageName":"64Play.png"}, "width":"64", "height":"64"}'>
     <asp:Image ID="imgPersonal" runat="server" ImageUrl="~/Images/Diagram/64Play.png" />
</div>

This is the code for Save and Load JSON
function saveJSON() {
     var json = diagram.save();
     var jsonStr = Sys.Serialization.JavaScriptSerializer.serialize(json);
      
     var txtDiagramSave= document.getElementById("txtDiagramSave");
     txtDiagramSave.value = js_beautify(jsonStr);
}
 
function loadJSON() {
     var txtDiagramSave= document.getElementById("txtDiagramSave");
     diagram.load(Sys.Serialization.JavaScriptSerializer.deserialize(txtDiagramSave.value));
}

This is my saved JSON
{
    "shapes": [{
        "id": "StartProcess_1242084a-6aa2-4320-8b89-accf2cd22f25",
        "hover": {},
        "cursor": "pointer",
        "content": {
            "align": "center middle",
            "text": "",
            "CustomText": "Start",
            "TextX": "18",
            "TextY": "70",
            "ImageName": "64Play.png"
        },
        "selectable": true,
        "serializable": true,
        "enable": true,
        "type": "rectangle",
        "path": "",
        "autoSize": true,
        "visual": null,
        "x": 134,
        "y": 104,
        "minWidth": 20,
        "minHeight": 20,
        "width": 65,
        "height": 65,
        "editable": {
            "connect": true
        },
        "connectors": [{
            "name": "Top",
            "description": "Top Connector"
        }, {
            "name": "Right",
            "description": "Right Connector"
        }, {
            "name": "Bottom",
            "description": "Bottom Connector"
        }, {
            "name": "Left",
            "Description": "Left Connector"
        }, {
            "name": "Auto",
            "Description": "Auto Connector"
        }],
        "rotation": {
            "angle": 0
        },
        "undoable": false
    }, {
        "id": "Personal_3993f4ff-956e-4d46-a939-18c84fcb4162",
        "hover": {},
        "cursor": "pointer",
        "content": {
            "align": "center middle",
            "text": "",
            "CustomText": "Personal",
            "TextX": "8",
            "TextY": "70",
            "ImageName": "64ManPencil.png"
        },
        "selectable": true,
        "serializable": true,
        "enable": true,
        "type": "rectangle",
        "path": "",
        "autoSize": true,
        "visual": null,
        "x": 295,
        "y": 99,
        "minWidth": 20,
        "minHeight": 20,
        "width": 65,
        "height": 65,
        "editable": {
            "connect": true
        },
        "connectors": [{
            "name": "Top",
            "description": "Top Connector"
        }, {
            "name": "Right",
            "description": "Right Connector"
        }, {
            "name": "Bottom",
            "description": "Bottom Connector"
        }, {
            "name": "Left",
            "Description": "Left Connector"
        }, {
            "name": "Auto",
            "Description": "Auto Connector"
        }],
        "rotation": {
            "angle": 0
        },
        "undoable": false
    }],
    "connections": [{
        "from": {
            "id": "StartProcess_1242084a-6aa2-4320-8b89-accf2cd22f25"
        },
        "to": {
            "id": "Personal_3993f4ff-956e-4d46-a939-18c84fcb4162"
        },
        "id": "h4upyHsjPm",
        "hover": {
            "stroke": {}
        },
        "cursor": "pointer",
        "content": {
            "align": "center middle",
            "text": "",
            "color": "#444444"
        },
        "selectable": true,
        "serializable": true,
        "enable": true,
        "startCap": "none",
        "endCap": "ArrowEnd",
        "points": [],
        "stroke": {
            "width": 2,
            "color": "#6c6c6c"
        },
        "selection": {
            "handles": {
                "width": 8,
                "height": 8,
                "fill": {
                    "color": "white"
                },
                "stroke": {
                    "color": "#444444"
                }
            }
        }
    }]
}

However, after I loaded the saved JSON, it was changed to be like this. (I lost the showing images, and connection is blank)
{
    "shapes": [{
        "id": "StartProcess_1242084a-6aa2-4320-8b89-accf2cd22f25",
        "hover": {
            "opacity": 0.2
        },
        "cursor": "pointer",
        "content": {
            "align": "center middle",
            "text": "",
            "color": "#444444",
            "CustomText": "Start",
            "TextX": "18",
            "TextY": "70",
            "ImageName": "64Play.png"
        },
        "selectable": true,
        "serializable": true,
        "enable": true,
        "type": "rectangle",
        "path": "",
        "autoSize": true,
        "visual": null,
        "x": 134,
        "y": 104,
        "minWidth": 20,
        "minHeight": 20,
        "width": 65,
        "height": 65,
        "editable": {
            "connect": true
        },
        "connectors": [{
            "name": "Top",
            "description": "Top Connector"
        }, {
            "name": "Right",
            "description": "Right Connector"
        }, {
            "name": "Bottom",
            "description": "Bottom Connector"
        }, {
            "name": "Left",
            "Description": "Left Connector"
        }, {
            "name": "Auto",
            "Description": "Auto Connector"
        }],
        "rotation": {
            "angle": 0
        },
        "stroke": {
            "width": 0
        },
        "fill": {
            "color": "#4cc5da"
        },
        "connectorDefaults": {
            "fill": {
                "color": "#444444"
            },
            "stroke": {
                "color": "white"
            },
            "hover": {
                "fill": {
                    "color": "white"
                },
                "stroke": {
                    "color": "#444444"
                }
            }
        },
        "undoable": false
    }, {
        "id": "Personal_3993f4ff-956e-4d46-a939-18c84fcb4162",
        "hover": {
            "opacity": 0.2
        },
        "cursor": "pointer",
        "content": {
            "align": "center middle",
            "text": "",
            "color": "#444444",
            "CustomText": "Personal",
            "TextX": "8",
            "TextY": "70",
            "ImageName": "64ManPencil.png"
        },
        "selectable": true,
        "serializable": true,
        "enable": true,
        "type": "rectangle",
        "path": "",
        "autoSize": true,
        "visual": null,
        "x": 295,
        "y": 99,
        "minWidth": 20,
        "minHeight": 20,
        "width": 65,
        "height": 65,
        "editable": {
            "connect": true
        },
        "connectors": [{
            "name": "Top",
            "description": "Top Connector"
        }, {
            "name": "Right",
            "description": "Right Connector"
        }, {
            "name": "Bottom",
            "description": "Bottom Connector"
        }, {
            "name": "Left",
            "Description": "Left Connector"
        }, {
            "name": "Auto",
            "Description": "Auto Connector"
        }],
        "rotation": {
            "angle": 0
        },
        "stroke": {
            "width": 0
        },
        "fill": {
            "color": "#4cc5da"
        },
        "connectorDefaults": {
            "fill": {
                "color": "#444444"
            },
            "stroke": {
                "color": "white"
            },
            "hover": {
                "fill": {
                    "color": "white"
                },
                "stroke": {
                    "color": "#444444"
                }
            }
        },
        "undoable": false
    }],
    "connections": []
}

I try to solve the load JSON problem by using "visualTemplate" like this, but it breaks the diagram
function visualTemplate(options) {
     var diagram = kendo.dataviz.diagram;
     var g = new diagram.Group();
     var dataItem = options.dataItem;
 
     g.append(createCustomShape(dataItem));
     return g;
};


Slav
Telerik team
 answered on 29 Jan 2015
3 answers
153 views
Hello,

I'm using a Masterpage with .NET 4.0 and a RadSkinManager. Without obviously changing anything in the masterpage, I'm getting a NRE in one of my 3 content pages. The question is why is this only happening in one page and how to get RadSkinManager applied continously to all content pages?
My masterpage head is the following:
<head id="Head1" runat="server">
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title></title>
  <telerik:RadSkinManager ID="rsm" runat="server" Skin="WebBlue"></telerik:RadSkinManager>
  <link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
  <asp:ContentPlaceHolder ID="HeadContent" runat="server"></asp:ContentPlaceHolder>
</head>

The error:
[NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.]
   Telerik.Web.UI.RadSkinManager.Page_PreRender(Object sender, EventArgs e) +67
   System.EventHandler.Invoke(Object sender, EventArgs e) +0
   System.Web.UI.Control.OnPreRender(EventArgs e) +92
   System.Web.UI.Control.PreRenderRecursiveInternal() +83
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +974
Peter Filipov
Telerik team
 answered on 29 Jan 2015
1 answer
143 views
Hi all,

I am dynamically generating a RadGrid from code behind, which was perfectly working of retrieving the RadGrid Item data for hidden columns.

But, now I need to upgrade telerik version from "2011.1.413.35" to "2014.3.1209.35".

After doing this upgrade, the above method of retrieving the RadGrid Item data for hidden columns is not working, in other ways I am getting &nbsp; in place of the value.

Here is my sample code to create grid:
I am putting xmldatasource to fill the RadGrid.

radGrid.MasterTableView.Columns.Add(_CreateColumn("ID", "", Unit.Percentage(0), false));

private GridBoundColumn _CreateColumn(string dataField, string text, Unit width, Boolean readOnly)
    {
        GridBoundColumn boundColumn = new GridBoundColumn();

        boundColumn.DataField           = dataField;
        boundColumn.HeaderText          = text;
        boundColumn.SortExpression      = boundColumn.DataField;
        boundColumn.HeaderStyle.Width   = width;
        boundColumn.ReadOnly            = readOnly;
        boundColumn.Visible             = (width.Value == 0 ? false : true);

        return boundColumn;
    }.

Sample code to retrieve item value:
RadGrid radGrid = (RadGrid)control;
foreach (GridDataItem grdItem in radGrid.Items)
{
     string ID = grdItem["ID"].Text;
}

But the ID = &nbsp;   which should be some value which I filled though xmldatasource.

Please provide some bunch of code or any kind of help will be appreciated.

Maria Ilieva
Telerik team
 answered on 29 Jan 2015
2 answers
120 views
Hi,

I am using a RadTreeList control and I want to set the selected property (checkbox) of a row, depending on a value from the datasource.
This is my code:

<telerik:RadTreeList ID="lstAanbod" runat="server" CssClass="_radgrid" OnNeedDataSource="lstAanbod_NeedDataSource" DataKeyNames="NR" ParentDataKeyNames="PARENT_NR" ClientDataKeyNames="DOSSIER_ID, PROFIEL_ID, GESELECTEERD"  EnableEmbeddedSkins="false" BorderStyle="None" GridLines="None" ShowFooter="true" AutoGenerateColumns="false" AllowMultiItemSelection="true">
    <ItemStyle HorizontalAlign="Left"></ItemStyle>
    <Columns>
        <telerik:TreeListSelectColumn HeaderStyle-Width="38px" UniqueName="SelectColumn"></telerik:TreeListSelectColumn>                   
        <telerik:TreeListBoundColumn HeaderStyle-Width="10%" DataField="CODE" HeaderText="Code"></telerik:TreeListBoundColumn>
        <telerik:TreeListBoundColumn HeaderStyle-Width="60%" DataField="TITEL" HeaderText="Titel"></telerik:TreeListBoundColumn>
        <telerik:TreeListBoundColumn HeaderStyle-Width="10%" DataField="NIVEAU" HeaderText="Niveau"></telerik:TreeListBoundColumn>
        <telerik:TreeListBoundColumn HeaderStyle-Width="10%" DataField="DOSSIER_ID" HeaderText="Niveau" Visible="false"></telerik:TreeListBoundColumn>
        <telerik:TreeListBoundColumn HeaderStyle-Width="10%" DataField="PROFIEL_ID" HeaderText="Niveau" Visible="false"></telerik:TreeListBoundColumn>     
    </Columns>         
    <ClientSettings Selecting-AllowItemSelection="true" Selecting-UseSelectColumnOnly="true" Selecting-AllowToggleSelection="true" ClientEvents-OnItemSelected="OnClientNodeSelected" ClientEvents-OnTreeListCreated="treeListCreated"></ClientSettings>     
</telerik:RadTreeList>


function UpdateAllChildren(currNode, nodes, nodecount, checked) {           
    var i;
    for (i = 0; i < nodecount; i++) {
        if (checked) {
            nodes[i].set_selected(true);
        }
        else {
            nodes[i].set_selected(false);
        }
    }
}
 
function treeListCreated(sender, args) {
    var items = sender.get_dataItems();
     
    for (var i = 0; i < items.length; i++) {
        var item = items[i];               
        if (item.get_dataKeyValue("GESELECTEERD") == "True") {                   
            item.set_selected(true);
        }
    }
}

However, when I run my page, I get an error on the line 'item_set_selected(true)' :

Unhandled exception at line 808, column 27 in http://localhost:11488/ScriptResource.axd? ...
0x800a138f - Runtime-fout JavaScript: Unable to get property '_selectedIndexes' of undefined or null referenced

What am I doing wrong?
Kostadin
Telerik team
 answered on 29 Jan 2015
1 answer
165 views
Hey !

I want to create a filter Template in Code Behind, but it's hard for me, can you help me ?

I would like to be able to filter the names of technicians with a combobox !

This is my code :

protected void Page_Load(object sender, EventArgs e)
{
    GetGestionDoc();
}

{
    if (Session["NumStation"] != null)
    {
        int numStation = Convert.ToInt32(Session["NumStation"]);
        document = entities.V_RAPPORTSVALIDES.Where(p => p.ID_STATION == numStation).ToList();
 
        List<DocumentObject> newList = new List<DocumentObject>();
 
        foreach (var item in document)
        {
            DocumentObject o = new DocumentObject(item.TYPE_VISITE, item.TYPE_DOCUMENT, Convert.ToDateTime(item.DATE_DOCUMENT), Convert.ToInt16(item.ANNEE_RAPPORTANNUEL), item.NOM_TECHNICIEN);
            newList.Add(o);
        }
 
        RadCommentGrid.DataSource = newList;
        RadCommentGrid.DataBind();
 
        ChangeHeaderName();
    }
}

private void ChangeHeaderName()
{
    foreach (GridColumn column in RadCommentGrid.MasterTableView.AutoGeneratedColumns)
    {
        switch (column.OrderIndex)
        {
            case 2:
                column.HeaderText = "Date du document";
                break;
            case 3:
                column.HeaderText = "Type de document";
                break;
            case 4:
                column.HeaderText = "Nom du technicien";
                break;
            case 5:
                column.HeaderText = "Type de visite";
                break;
            case 6:
                column.HeaderText = "Année du rapport annuel";
                break;
        }
    }
 
    GridColumn columnDateDoc = RadCommentGrid.MasterTableView.AutoGeneratedColumns.Where(p => p.UniqueName == "DATE_DOCUMENT").FirstOrDefault();
    columnDateDoc.OrderIndex = 1;
 
    GridColumn columnTypeDoc = RadCommentGrid.MasterTableView.AutoGeneratedColumns.Where(p => p.UniqueName == "TYPE_DOCUMENT").FirstOrDefault();
    columnTypeDoc.OrderIndex = 2;
 
    GridColumn columnTechnicien = RadCommentGrid.MasterTableView.AutoGeneratedColumns.Where(p => p.UniqueName == "NOM_TECHNICIEN").FirstOrDefault();
    columnTechnicien.OrderIndex = 3;
 
    GridColumn columnVisite = RadCommentGrid.MasterTableView.AutoGeneratedColumns.Where(p => p.UniqueName == "TYPE_VISITE").FirstOrDefault();
    columnVisite.OrderIndex = 4;
 
    GridColumn columnAnnee = RadCommentGrid.MasterTableView.AutoGeneratedColumns.Where(p => p.UniqueName == "ANNEE_RAPPORTANNEE").FirstOrDefault();
    columnAnnee.OrderIndex = 5;
}


I see in your demo, you can create a filter with a radcombobox but its in XML :

<telerik:RadComboBox
     
    ID="RadComboBoxTitle"
     
    DataSourceID="SqlDataSource2"
     
    DataTextField="ContactTitle"
     
    DataValueField="ContactTitle"
     
    Height="200px"
     
    AppendDataBoundItems="true"
     
    SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("ContactTitle").CurrentFilterValue %>'
     
    runat="server"
     
    OnClientSelectedIndexChanged="TitleIndexChanged">
     
    <Items>
        <telerik:RadComboBoxItem Text="All" />
    </Items>
     
</telerik:RadComboBox>

Eyup
Telerik team
 answered on 29 Jan 2015
1 answer
485 views
I have a gridview with column name "Domain"

BY default it shows a single filter att one time but i want multiple filter in one time in single column

My RadGrid Structure is this

DOMAIN
@yahoo.com
@gmail.com
@india.com


I want to filter domain other than @yahoo.com and @gmail.com

How to do that in RadGrid Filter ??
 
 
Eyup
Telerik team
 answered on 29 Jan 2015
1 answer
82 views
Hi,

is it possible or a planned feature to mark certain days as holidays inside the calender for planning the different tasks?
Thank you.

Regards,
Felix
Bozhidar
Telerik team
 answered on 29 Jan 2015
1 answer
103 views
Hi,

is it possible to create a task inside the gantt-chart without a determination of the start time and end time? Because in some project plannings I want to create some tasks but do not know when they are going to start or end. Thanks.

Regards,
Felix
Bozhidar
Telerik team
 answered on 29 Jan 2015
1 answer
162 views
I want to bind the RadScheduler control from dataset, I have set all the required properties like DataStartField, DataEndField, DataSubjectField, DataKeyField etc, but couldn't able to show appointments on the Control. For your information I'm getting data in dataset from SQL Server Database and there is no chance that dataset is null. Please help with both RadScheduler design and aspx.cs part.
Boyan Dimitrov
Telerik team
 answered on 29 Jan 2015
8 answers
212 views
We're using the DiffEngine component to identify changes between saved versions of the Editor content.  These version changes must then be approved by a Content Approver (user). There are two problematic scenarios we have encountered.

Scenario 1:

version 1 html:  <a title="xxx" href="http://wwww.test.com/xxxxx.pdf">a link</a>
version 2 html:  <a title="yyyy" href="http://wwww.test.com/yyyyyyy.pdf">a link</a>

The DiffEngine reports no differences in these two HTML snippets. This is a major problem for us. The linked document (href) was changed and the "title" content was changed; we need for these changes to be identified so they can be approved by the Content Approver user.


Scenario 2:

version 1 html:  <img src="http://demos.telerik.com/aspnet-ajax/editor/images/editor.jpg" alt="telerik" />
version 2 html:  <img src="http://demos.telerik.com/aspnet-ajax/editor/images/editor.jpg" alt="telerik">

The DiffEngine reports a difference in these two html snippets, despite the fact that only the closing tag changed.

Here's the output of the DiffEngine:

<table class="diff_deleted"><tr><td><img src="http://demos.telerik.com/aspnet-ajax/editor/images/editor.jpg" alt="telerik" /></td></tr></table><table class="diff_new"><tr><td><img src="http://demos.telerik.com/aspnet-ajax/editor/images/editor.jpg" alt="telerik"></td></tr></table>


Scenario 2 is more of a nuisance, but it would be nice if the DiffEngine would ignore something as trivial as a closing tag change.

Scenario 1 is a show-stopper for us.  It is possible to have the DiffEngine identify the changed href and the changed title in this scenario?

Thanks,
Trevor.


Ianko
Telerik team
 answered on 29 Jan 2015
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?