SYNCFUSION BLOG

Tuesday Sep 7, 2010 at 01:19 AM | Posted by: | Category: ASP.NET MVC

In this blog post we will have a look at some of the Visual studio extensions that have been created for Syncfusion MVC components. Given the nature of MVC products, a bit of configuration needs to be done before we can actually start with using a required control in the application. I call this as the Configuration phase of the application . Lets look at the steps in this phase:

1. Adding Reference Assemblies – add the required assemblies .

2. Adding Scripts – add the Jquery and the MicrosoftAjax scripts.

3. Adding Codes to the Web.config File – add the appropriate namespaces and register the handlers.

4. Adding Resource Manager -  register the MvcStaticResourceManager that helps in registering the css and scripts required to display and add functionality to the controls.

Once we are done with the Configuration phase, we may then move to the design phase where we actually start designing the application by using the desired controls.

In this blog post I will focus my attention to the configuration phase.  Obviously, all the above mentioned configuration steps are mandatory in order to start using the controls, but wouldn’t be great if we could just bypass this phase and start designing the application right away. Most other platforms come with the luxury of a toolbox and a designer where you can quickly drag and drop the controls unlike MVC. So in order to compensate (in a way)  for this, we have created predefined project templates for all our MVC controls namely Grid, Tools, Gauge, Schedule and Chart . These predefined project templates will take care of all the configurations required in order to start using a particular MVC control, so you can focus on the design part alone.

The following steps explain how you can start using the custom project templates:

1. Download the project templates for VS2010. Unzip the folder ‘SyncfusionMVC’. This folder contains the project templates for all the Syncfusion MVC products namely Grid, Tools, Schedule, Chart and Gauge.

clip_image001

2. By default , the project templates in VS2010 are stored in the following location:

%UserProfile%\Documents\Visual Studio 2010\Templates\ProjectTemplates

As we have created the templates for C# alone , it will be more meaningful to place them under the folder Visual C# .  (Note: Do not unzip the inner folders which are shown in the image above)

clip_image002

Figure 1: Syncfusion MVC project templates

3. Now restart your Visual Studio 2010 and click on New Project . Expand the Visual C# node and you will find the SyncfusionMVC node as a child node.

clip_image003

As you see on the right , the project templates for all the products are displayed. To use them, just select the appropriate template and start using the controls right away.

To show how really effortless it is to get started with using the Syncfusion MVC controls using these templates, let us create a simple application using the Syncfusion RichTextEditor control (RTE). So to use the RTE control, we first navigate to VS2010 --> New Project –> Visual C# –> Syncfusion MVC, then select MvcToolsApplication project template. Name the application and click OK.

clip_image004

This will create a new MVC application with all the predefined settings ( which we call as the steps of the Configuration phase).

As you will see in the References section, the Tools and Shared Mvc references are already added.

clip_image005

The Web.Config file will contain the assembly references , the namespaces and all the handlers. Also the scripts and the RegisterStaticResources() will be added in the Site.Master .

clip_image006

clip_image007

Now all that we will have to do is create an object of the RTE control in the view.

clip_image009

Run the solution and up comes the RTE on your screen. !!!

clip_image010

More in Store!

Empty projects

In the same way , all other projects can be configured in just one click (by using this template ) and you can straight away start designing your application. The project templates attached in this blog are derived from default MVC 2 project templates and therefore they will contain all the junk that come along with it. We will also provide similar Empty MVC project templates (just as MS does) in our upcoming release (2010 Volume 4). These project templates will get installed automatically along with the setup for MVC controls in our upcoming version.

Version Manager- VS2010 Add-In

Apart from this we will also provide a VS2010 Add-in for configuring the version numbers in these project templates. By default we will upgrade the project templates to refer to the latest version of the assemblies installed , however if you are using any other version, then this add-in can be used to update the version in your Web.Config files.

Its not over yet!

Item Templates

So with these project templates , the configuration phase is taken care of! How would it be if we go one more step ahead and configure the control too for you . Here comes the T4 template to the rescue! We will provide custom item templates for our grid and editor controls , which make use of the strongly typed views , so that binding to these controls also becomes a one step process just as the configuration phase. Stay tuned for a preview of the Item templates , will blog about them in my next post.

Download Syncfusion MVC Project Templates for VS2010 here: 

Download-128x128

Wednesday Jun 16, 2010 at 08:14 PM | Posted by: | Category: ASP.NET MVC

With the upcoming 2010 Volume 3 release, several cool features are going to be added to the Syncfusion Grid MVC control. One among them is the support to drag and drop records from the grid to other DOM elements.

This feature allows you to select multiple rows (using jQuery UI- Selectable) and drag and drop the selected rows to any other element which is specified in the TargetHtmlElementId property of the grid. Let us look at a simple code snippet for using the drag and drop functionality in the grid:

<%=Html.Grid<Orders>("GridSrc")
                         .Datasource(Model)
                         .Column(column =>
                         {
                             column.Add(p => p.OrderID).HeaderText("Order ID");
                             column.Add(p => p.EmployeeID).HeaderText("Employee ID");
                             column.Add(p => p.CustomerID).HeaderText("Customer ID");
                             
                         })
                        .AllowRowsDragging(true)
                        .TargetHtmlElementId("#GridDest")        
                        .RowsDraggingMode(DragandDropMode.GhostRows)
                        .RowsDroppingMapper("Dragged")
                        .ClientSideEvents(events => {
                            events.OnRowDropping("OnDropping");
                            events.OnRowDropped("OnDropped");
                        })
                          %>

Here, Model is the data source, OnDropping and OnDropped are the event handlers, and the target element in this case may be another grid (say DestGrid).


Properties:
Let’s have a look at the properties:

  1. AllowRowsDragging - If true, it enables the drag and drop functionality and vice versa.
  2. TargetHtmlElementId - (type: string) This property sets the target element to which the records are to be dropped. The value must be specified like a normal selector.

Example:

  • To represent ID: “#TargetID”
  • To represent class: “.TargetClassname”


3. RowsDroppingMapper - This property sets the mapping string and enables us to perform some action when the records are dropped on the target element. For instance, if we move the records from one grid to another grid, we may have to remove those records from our source grid. Therefore we may specify the ActionResult to the RowsDroppingMapper to perform the user-defined actions.

4. RowsDraggingMode - Two dragging modes are provided:


1.    Normal: In this mode, just the number of records being selected is displayed while dragging.

image

2. GhostRows: In this mode, a ghost copy of the selected rows is displayed while dragging.

 

image

 

Events

Two client-side events are provided.

  1. OnRowDropping is triggered just before the records are dropped into the target element. This can be used to perform some validation checks before dropping the records and we may even cancel the dropping if required.
  2. OnRowDropped is triggered soon after the records are dropped. This can be used to update the target element.

And now, as explained previously, the ActionResult to perform user-defined actions can be defined in the controller page and specified to the RowsDroppingMapper. Therefore, the updating of the source grid is taken care of with the help of this ActionResult. But there may also be a need to perform some operations on the destination grid once the rows are dropped onto it. This is the point where the above mentioned client-side events come into picture. We may use the OnRowsDropping event to just display a waiting pop-up when the rows are dropped. But the OnRowDropped event is triggered after the records have been dropped on the destination grid, so we can utilize this to define the actions to be performed on the target grid.

 

function OnDropping(grid, EventArgs)
             {
           //perform some operation say, show a waiting pop up.
            }
 function OnDropped(grid, EventArgs) {
            
            var records = EventArgs.data;
            var params = { };          
            var visibleColumns = grid.get_VisibleColumnName();
               //To send the dropped records to the ActionResult  
             $.each(records, function(i, record) {
                $.each(visibleColumns, function(j, value) {
                    params["Records[" + i + "]." + this] = record[value];
                });
             });
            var callback = $.ajax({
                type: "post",
                url: "Dropped",//ActionResult URL to update the target grid
                data: params,
                dataType: 'html',
                success: function(data) {
                    $("#DestGrid")[0].innerHTML = data;
                    $.fn.sfEvalScripts(data);                                   }
            });                          
        }
        

 

And finally the ActionResults may be defined as follows:

   [AcceptVerbs(HttpVerbs.Post)]
   public ActionResult Dragged(List<Orders> Records)
     {
           //perform some operation to update the source grid (say update the database)
     }
   [AcceptVerbs(HttpVerbs.Post)]
    public ActionResult Dropped(List<Orders> Records)//Records contain the dropped records
      {
          //perform some operation to update the destination grid
      }

 

So, this is just one scenario of dragging and dropping records from one grid to another. We may also drop records onto other DOM elements. Other features available in the upcoming release include exporting to Excel, custom formatting, custom binding, etc. Do check our website for more details on the release dates and feature updates.

Wednesday Jun 16, 2010 at 01:52 AM | Posted by: | Category: Silverlight

With Volume 3 being the main release for Essential Diagram for Silverlight, the most awaited Save and Load feature will be available in this release. The Save and Loads methods will be analogous to the WPF counterpart and will be available as public methods in the DiagramControl class. The Save method will have three overloads

  • Save()- Opens a Save File dialog box to allow the user to select a location to save the XAML file.

  • Save(Stream stream)- Enables saving to a memory stream.

  • Save(string filename)- Enables saving directly to a file.

               Similarly the Load method will also have three overloads:
  • Load()- Opens a Load File dialog box to allow the user to select a location to load the XAML file from.

  • Load(Stream stream)- Enables loading from a memory stream.

  • Load(string filename)- Enables loading a XAML file.

     

    Along with the support to save and load within the Silverlight application, the support to load a XAML file from its WPF counterpart will also be provided. However, this will have some limitations. Triggers and DrawingImages (which are not supported in Silverlight) saved in the WPF XAML file will not be loaded and will be ignored. Apart from this, several other features will be available, namely:

  • Horizontal and Vertical Rulers.

  • Label Editor for Nodes and LineConnectors

  • Filtering support in the SymbolPalette

  • Connection ports for Nodes

  • Radial Tree Layout

  • Grouping and Ungrouping of diagram objects

  • Data binding support

    Do check our website for more details on the release dates and feature updates.

  • Tuesday Jun 15, 2010 at 11:30 PM | Posted by: | Category: Silverlight | WPF

    Most diagrams require users to specify the dimensions of each node object added to the drawing area. This is a big limitation given the dynamic nature of the diagram nodes and the vast extent of content that can be hosted inside them. It becomes very difficult to predetermine the dimensions of the content that is going to be hosted inside the nodes. Most of the time we may take a pessimistic approach and specify a very large width so that all the content fits in, or we may end up getting the content trimmed. For instance, consider a scenario where you want to create an organizational chart of a company and you wish to show the name of the managers and the employees under them.  Let’s fix the width of the node as 120 pixels and the height as 60 pixels and see the output:

        

    NodeResizing_1

    The width (120 pixels) that has been specified suits two of the four nodes; however, the designation of “Joe Robert” does not fit within the specified width and is therefore cut.  Same is the case with the last node. Now one possible solution, as specified previously, is to specify a width large enough to fit all the content. So, maybe a width of 150 pixels will suffice the needs with respect to this scenario. However, clearly this is not a generic solution as we will have the same issues when more nodes with larger text are added. Therefore, practically the best solution will be not to specify any width at all and let the nodes stretch themselves to fit their content. Essential Diagram for WPF provides this support. The diagram will look something like this:

    NodeResizing_2

    Now we see that the nodes themselves intelligently calculate the space needed to fit the content and expand just enough to fit. The same functionality has been implemented in our Silverlight version of Essential Diagram. I will blog more about the upcoming features in the Silverlight version, including the much awaited Save and Load compatibility between WPF and SL diagrams.

    Blog Archive