Author Topic: Run validation problem when I paste several records to my gird.  (Read 3606 times)

noctrona

  • Pro Enterprise
  • Jr. Member
  • *
  • Posts: 82
    • View Profile
Hi,

I have a problem about the validation.
In my page, I write some js codes can let user copy records from an excel and paste these records in my

pggrid. One row or multiple rows at one time. And I will check the dataIndx to set corresponding value for

each column.

As our general way, when user edit a cell and input some value which met my validation, I will change the

cell border color and display the customized error message next to this cell. So I want to achieve the same

effect after my paste operation.

I add the following code when I set a value for a cell:
Code: [Select]
$("#grid_json").pqGrid( "editCell", { rowIndx: rowIndx + i, dataIndx: colModel[m].dataIndx} );
                                           
var isValid = $("#grid_json").pqGrid("isValid", { dataIndx: colModel[m].dataIndx, value: value}).valid;
if (!isValid) {
    $("#grid_json").find(".pq-editor-focus").css({ "border-color": "red" });
    return false;
}
First, I set this column as the edit model. Then like the general, I check this cell with the validation. By

this code, for example,
I create two new line in my gird
Copy two row records from my excel(one column has the invalid value.).
Paste them in my gird.
And the result is the invalid cell will highlight and display the error message. But other cell, the valid

value didn't set in cell.


Then I remove "return false;" this statement. And try the above steps again. The result is the valid value

can set for my grid, but the invalid cell is empty. It's the display value didn't display but the invalid set

for this cell. Then I enter edit model for this invalid cell and the invalid value can display with error

message.


So the effect I desired is when I paste records in grid, all the invalid cell can display error message. Is

that possible?


Thank you!

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6310
    • View Profile
Re: Run validation problem when I paste several records to my gird.
« Reply #1 on: June 05, 2014, 04:27:40 pm »
Only one cell and hence only one validation error message can be shown at a time.

There is no need to enter into edit mode while doing validations. isValid automatically makes the cell enter into edit mode when it founds an invalid cell.

You can take the help of a similar case. http://paramquery.com/pro/demos/editing_batch line 28-31. In this demo multiple rows can be added by new product button. Validations are run when Accept changes button is clicked.
« Last Edit: June 05, 2014, 04:32:24 pm by paramquery »