I am trying DevExpress ASPSpreadsheet Control with VISEJ 2.05 but it do not eorks well. AddRow, DeleteRow and any layout changes after control being loaded do not works.
What may be the problem?
Public Class CDevexSpreadSheet
Inherits Wisej.Web.Ext.AspNetControl.AspNetWrapper(Of DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet)
Dim WithEvents OWrapedControl As DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet = Nothing
Public Sub New()
Me.Dock = Wisej.Web.DockStyle.Fill
AddHandler DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet.CellValueChanged, AddressOf CStaticEventHandlers.EventHandelr_CDevexSpreadSheet_CellValueChanged
Private Sub DEVEXGrid_LoadComplete(sender As Object, e As EventArgs) Handles Me.LoadComplete
Dim OMyWebComponentWRAPED As DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet = CType(Me.WrappedControl, DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet)
Public Event CEventComponentExposer(InOMyWebComponentWRAPED As DevExpress.Web.ASPxSpreadsheet.ASPxSpreadsheet)
It all works!
But I am still not able to get CELL CHANGE event. Would you help with this please?
I just tried, the AspNetWrapper control in Wisej works very well. The problem is that ASP.NET doesn’t work the same way as Wisej and your code cannot update the DevExpress ASPxSpreadsheet control because you are saving a reference to the instance that doesn’t exist anymore. Wisej makes it too easy… 🙂
The same approach used in your sample doesn’t work in any framework, including ASP.NET itself. ASP.NET controls do not exist past the page cycle. VB.NET (or C#) code can interact with an ASP.NET control only when the page is initialized or loaded (which is during a page request from the browser). After the response (which is a large concatenated HTML string) is sent back, the ASP.NET controls are discarded. They will be all recreated from scratch at the next request (or postback for a form).
If the clicks in your sample were coming from an ASP.NET page, it would work because the click issues a full page request and the entire ASPxSpreadsheet is recreated. Wisej is a Single Page Application (SPA) system completely based on asynchronous (ajax) communications. Very similar to a single ASP.NET update panel. If you tried to update the ASPxSpreadsheet in an ajax request in ASP.NET it would not work. See https://www.devexpress.com/Support/Center/Question/Details/T399187/how-to-refresh-aspxspreadsheet-without-refreshing-the-whole-page.
This is why the AspNetWrapper shows the WrappedControl property which is the reference to the live instance of the ASP.NET control. If you save that reference in your code you are referring to a “dead” instance past the Page_Init, Page_Load (etc, see reference doc).
Basically, ajax code can use ASP.NET control only during a page request.
You can do this:
Add a method to the wrapper
Public Sub Test() doSomething = True Update() End Sub Dim doSomething As Boolean Private Sub CDevexSpreadSheet_Init(sender As Object, e As EventArgs) Handles Me.Init If (doSomething) Then Me.WrappedControl.Document.Worksheets(0).Rows(1).FillColor = Drawing.Color.Red End If End Sub
Now you can call Test() at anything from an ajax event coming from a Wisej control. The method Test will call Update() which will reload the spreadsheet.
To prevent the full reloading, see the explanation at the DevExpress support forum: https://www.devexpress.com/Support/Center/Question/Details/T399187/how-to-refresh-aspxspreadsheet-without-refreshing-the-whole-page
You can assign the ClientInstanceName in Page_Init and you will find it on the client side.
Me.WrappedControl.ClientInstanceName = "Spreadsheet1"
Then in Test() instead of Update(), call this:
It will update the ASPxSpreadsheet using a postback as advised by DevExpress.
You may get other problems after this in your sample because the way it’s written it recreates the sheet on every load, which conflicts with the typical ASP.NET postback model. In the AspNetWrapper we also expose IsCallback and IsPostback. This way you can check if the load event is fired because of an ASP.NET postback.
In other words, anything you want to do to the ASPxSpreadsheet object can only be done while inside Page_Init or Page_Load or the other page initialization events.
I hope the sample project will do for the problem demonstration purpose.
After initialising the spreadsheet is like dead. Nor row add, hiding, painting and so on. Only cell value setting works.
Also I need active cell change event.
Please login first to submit.