jQuery UI Widgets Forums Grid Can't find "hidevalidationpopups" method in JqxGrid

This topic contains 5 replies, has 2 voices, and was last updated by  Yavor Dashev 1 week, 1 day ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author

  • npiccone
    Participant

    Hi all,
    i’m trying to implement validation of row for my grid.
    I’ve written my validation function and i’m able to use the method showvalidationpopup to show the validation error on the cell i’m validating.
    Now i want to hide that popup when the user starts to edit the invalid cell and reading on the forum i found that i should use hidevalidationpopups method, but it’s not recognized and leads to error.
    How comes? I searched on the documentation of jqxgrid too but i didn’t find any reference to that method. So how can i hide the validation popup?
    Thanks in advance


    Yavor Dashev
    Participant

    Hi npiccone,

    I have prepared a more suitable solution for you use case which doesn’t use showvalidationpopup and hidevalidationpopups methods but provides the functionality you want to achieve.

      columns: [
                   
                      { text: 'Product', datafield: 'productname', width: 200 },
                 
                      { text: 'Quantity', datafield: 'quantity', width: 70, align: 'right', cellsalign: 'right',
                      validation: function (cell, value) {
                            if (parseInt(value) < 0 || parseInt(value)  > 150) {
                    
                               return { result: false, message: "Quantity should be in the 0-150 interval" };
                            }
                            else {
                                return true;
                            }
                           
                           
                        } 
                     },
                      { text: 'Price', datafield: 'price', cellsalign: 'right', align: 'right', cellsformat: 'c2' }
                    ]

    Let me know if that works for you!

    Please, don’t hesitate to contact us if you have any questions!

    Best Regards,
    Yavor Dashev
    jQWidgets team
    https://www.jqwidgets.com


    npiccone
    Participant

    Hi Yavor,
    i will try your solution, but i have a question.
    I need to programmatically validate the columns of my grid before calling a web service to update database.
    Does this solution work in this case? I mean I have n Rows and i need to check that every row has quantity column > 0
    Hope i’ve been clear enough.


    Yavor Dashev
    Participant

    Hi npiccone,

    Well if you are going to update a database maybe this will not be the prefect for your use case because showvalidationpopup is more like of an UI feature.

    However if you want to programmatically validate the cells its better to bind for the cellvaluechanged event from which you can get the old and the new value of the edited cell and from there you can create your logic for validating the cell.

    More about it you can check out in the documentation of the jqxGrid:
    https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxgrid/jquery-grid-api.htm

    Please, don’t hesitate to contact us if you have any questions!

    Best Regards,
    Yavor Dashev
    jQWidgets team
    https://www.jqwidgets.com


    npiccone
    Participant

    Hi Yavor,
    maybe i wasn’t too clear in my previuos message.
    Before calling my web service i need to cycle alle the rows on my grid and check if quantity is filled. If quantity isn’t filled in a particular row, i want to show the validation message (that’s because i was using the showvalidationpopup) so the user can insert the missing data. When i add a new row only the quantity cell is not filled because the user have to insert, but the same user could skip quantity insertion so the value of the cell never changes.
    I just need to show a message on the cell not validated and when the user start editing the cell i have to hide the message.
    That’s it.
    The attached image shows what i mean
    Validation

    • This reply was modified 1 week, 2 days ago by  npiccone.
    • This reply was modified 1 week, 2 days ago by  npiccone.
    • This reply was modified 1 week, 2 days ago by  npiccone.

    Yavor Dashev
    Participant

    Hi npiccone,

    Yes now I understand you use case more clearly.

    I have prepared a code snippet which enables you to have this kind of functionality using ‘getcell’ method.

        $("#checkCell").click(function () {
                 
                   for( let i = 0; i < data.length; i ++){
                    var datafield = 'quantity';
                    var cell = $('#jqxgrid').jqxGrid('getcell', i, datafield);
    
                    
                        if(cell.value < 10 ) {
                          $("#jqxgrid").jqxGrid('showvalidationpopup', cell.row, "quantity", "Invalid Value");
                        }
                   }
                });

    However this may result in some delays of the UI that is why the best option is to bind for the ‘cellendedit’ event when the user edits the cells data and in it to check the value when the cells edit is finished.
    May concerns are because if your grid has a large number of data going through every cell may slow down the UI in this case.

    Please, don’t hesitate to contact us if you have any questions!

    Best Regards,
    Yavor Dashev
    jQWidgets team
    https://www.jqwidgets.com

    • This reply was modified 1 week, 1 day ago by  Yavor Dashev.
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.