GridWeb validation issues

Hi,

Thanks for your answer,

However, because the error message must be computed on server side (OnCellModifiedOnAjax), your suggestion does not fit for my needs.

@lswe,

Your issue has been resolved but I need to get confirmation from concerned developer from product team if it will suit your needs or not.

Hopefully we will get back to you soon.

@lswe,

As you need the error messages must be computed on server side so, we need to reconsider your requirements, it would be completely different implementation way. I have reopened your ticket “CELLSNET-45928” again. We will try to support your needs soon.

Once we have any new information, we will share it with you.

Thanks for your answer,

Please let me know when the fix will be available,

@lswe,

Please spare us little time (1-2 weeks or so) to evaluate your issue and to support your needs.

Once we have any new information, we will share it with you.

@lswe,

We will add: GridValidationType.CustomServerFunction in one of our upcoming fixes to support your requirements. The code could be something like following:
e.g
Sample code:

//first you need to implement the interface:GridCustomServerValidation
  class myservervali : GridCustomServerValidation
    {
       //if return string.empty the validate is passed,else you can return any related message which can be deal in ClientCallback function
        public string Validate(GridWorksheet sheet, int row, int col, string value)
        {
            if (row == 1)
            {//validate fail
                return "not passed";
                
            }

            else
            {//validate ok
                return string.Empty;
            }
        }
    }
 protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack&&!GridWeb45928.IsPostBack)
            {
            var gridValidationCollection = this.GridWeb45928.ActiveSheet.Validations;
            GridValidation gv = gridValidationCollection.Add();
            gv.AddArea(new GridCellArea(1,1,2,2)); 
            gv.ValidationType = GridValidationType.CustomServerFunction;
            gv.ServerValidation = new myservervali();

          //also need to set ClientValidationFunction  to deal with client logic when server validation fails and return message
            gv.ClientValidationFunction = "ValidationErrorClientFunction";
            }
        }

.aspx page:

 <script type="text/javascript" language="javascript">
         var lastselectvalue = null;
         function myCellSelect(cell) {
             var value = this.getCellValueByCell(cell);
             lastselectvalue = value;
             console.log("myonCellSelect:" + value + " row" + this.getCellRow(cell) + ",col:" + this.getCellColumn(cell));
         }
//decalare like this 
         function ValidationErrorClientFunction(cell,msg) {
             //Showing an alert message where "this" refers to GridWeb
             alert(this.id + msg);
             console.log("myonCellSelect:" + this.getCellRow(cell) + ",col:" + this.getCellColumn(cell));
             // 
             var who = this;
             //async raise alert 
             
             //restore to valid value 
             who.setValid(cell);
             setInnerText(cell.children[0], lastselectvalue);
             // this.setCellValueByCell(cell, lastselectvalue); 
         }

    </script>

......
 <cc1:GridWeb ID="GridWeb45928" runat="server" OnCellSelectedClientFunction="myCellSelect" >

You will also need jquery js lib.

Hope, this helps a bit.

@lswe

Thanks for using Aspose APIs.

Please download and try the following fix for your issue CELLSNET-45928 and let us know your feedback.


For sample code, please refer to the above post. i.e.

The issues you have found earlier (filed as CELLSNET-45928) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by Amjad_Sahi

The issues you have found earlier (filed as CELLSNET-45928) have been fixed in this update. Please also check the following article:* <a href="Install Aspose Cells through NuGet|Documentation

Hi,

I tried the code you suggested. However there is still an issue.

Here is what I have on client :

             function onCellError(cell) {
                ShowModalError("error", '<%=Resources.Resource.InvalidTypedValue%>');
                this.setValid(cell);
                setInnerText(cell.children[0], lastselectvalue);
            }

When I type a wrong value in a validation cell and then I tabulate, I got the error message and the cell value is restored to the last correct value so the behaviour is correct. However when I go back to this cell, the cell value changes and it displays the wrong value. This is not the expected behaviour. It seems that the setInnerText does not change deeply the cell value.

Could you please help me to figure out this issue?

Thanks,

@lswe,

Thanks for the code segment and some details.

See the document with example for your reference:

The example works fine as we tested, the older/valid value is restored fine in the relevant cells. Could you refer to it and try it with our latest version/fix: Aspose.Cells.GridWeb v18.3.x. If you still find any issue, kindly do create a sample project (runnable), zip it and post us to show the issue on our end, we will check it soon. Also provide steps details and screenshots to help to reproduce the issue.

Hi,

Thanks for your answer,

However I’m not able to make your code work. Please consider the attached file (6.9 KB). The A1 cell of this workbook contains a list validation based on some cell values. Could you please send me back a sample project which show me that your code work on this cell ?

Thanks,

@lswe,

Thanks for the template file.

I tried to accomplish the task as per the document example code but could not make it work with the cell (having list validation set on it). it seems to have some sort of clash with existing validation on the cell. I have logged an investigation ticket with an id “CELLSNET-46056” for your issue. We will look into it thoroughly and try to figure it out soon.

Once we have an update on it, we will let you know here.

@lswe,

We will add support for server-side validation for list data validation. We will support server-side validation for GridValidationType.List, GridValidationType.DropDownList and GridValidationType.CustomServerFunction:
e.g
Sample code:

GridValidation gv2 = gridValidationCollection.Add(new GridCellArea(3, 3, 4, 4));
                gv2.ValidationType = GridValidationType.List;
                StringCollection sc=new StringCollection();
                sc.Add("apple");
                sc.Add("egg");
                sc.Add("banana");
                sc.Add("cake");
                sc.Add("peach");
                sc.Add("orange");
                gv2.ValueList = sc;
                gv2.ServerValidation = new myservervali2();
                gv2.ClientValidationFunction = "ValidationError2";
                gv2.InputTitle = "please select fruit";
                gv2.InputMessage = "&^**^&--which is fruit";

........



  class myservervali3 : GridCustomServerValidation
    {

        public string Validate(GridWorksheet sheet, int row, int col, string value)
        {
            if (value.Equals("egg") || value.Equals("cake"))
            {
                return "not fruit";

            }

            else
            {
                return string.Empty;
            }
        }
    }
...
in aspx page:
  function ValidationError2(cell, msg) {
             //Showing an alert message where "this" refers to GridWeb
             //  alert(this.id + msg);
           alert(msg);
           
         }

We hope to support this in our upcoming version/fix.

Once the feature is supported or we have some other update on it, we will let you know here.

@lswe,

Please try our latest version/fix: Aspose.Cells.GridWeb v18.4.2

Your issue should be fixed in it.

Please refer to the code segment shared in the previous post.

Hi,

Thanks for your answer,

However I’m not able to make it work. Please consider the attached file 1 (6.9 KB) I sent you on Apr 17. On load, The A1 cell of this workbook is empty but it contains a list validation based on some cell values. When I typed “1 AAA” in this cell the OnCellErrorClientFunction handler displays the correct error message and seems to restore the cell value to the previous valid value (affected in the OnCellSelectedClientFunction handler). However, if I select another cell then go back to the A1 cell, cell value became “1 AAA” which is not a correct value according to the validation as if setInnerText(cell.children[0], lastselectvalue) does not write deeply the cell value. Again, could you please send me back a sample project which show me that your code work on this cell ?

Thanks,

@lswe,

Thanks for the template file and details.

Could you share the sample project (runnable) on how you write code and pop up error dialog(s), etc. to demonstrate the issue, we will check and may log an appropriate ticket(s) for the issue (if found), so it could be figured out soon.

A sample project is a bit tricky for me but I can send you piece of codes :

Default.aspx

        <acw:GridWeb ID="GridWeb1" runat="server" Width="100%" Height="100%" ShowLoading="true" XhtmlMode="true"
            PresetStyle="Standard" EnableAJAX="true" EnableAsync="true" RenderHiddenRow="true"
            OncellModifiedOnAjax="cellmodifiedserver" OnCellErrorClientFunction="onCellError" OnCellSelectedClientFunction="myCellSelect"
            OnCellUpdatedClientFunction="cellupdated">
        </acw:GridWeb>

app.js

    var lastselectvalue = null;
    function myCellSelect(cell) {
        var value = this.getCellValueByCell(cell);
        lastselectvalue = value;
        console.log("myonCellSelect:" + value + " row" + this.getCellRow(cell) + ",col:" + this.getCellColumn(cell));
    }
    function onCellError(cell) {
        alert("error", 'Wrong value');
        this.setValid(cell);
        setInnerText(cell.children[0], lastselectvalue);
    }

Hope this help,

Thanks,

@lswe,

I tried to accomplish the task by using my own code with existing validation in your template file but it does not work. May be it is a limitation and we cannot customize (with dialog(s)) existing validations in GridWeb. Therefore, I requested you to post a simple sample project (runnable) to show the issue, so we could evaluate based on your project with artifacts and try to figure it out soon (if possible).

As you told me that it does not work on your side, why do you need a sample project ? Did you reproduce this issue and don’t know how to figure it out ? I can’t understand…

If you cannot reproduce the issue, please send me your sample project with my workbook and let me modify it to show you the issue.

Thanks,