Bootstrap-table: How validate after edit?

Created on 12 Apr 2018  路  8Comments  路  Source: wenzhixin/bootstrap-table

I tried a several times but no success. I need validate my new value after edit it. My table is all config in HTML, not in JS.

<table id="gridTable" data-url="getList.php" data-resizable="true" data-toggle="table" data-classes="table table-hover" data-striped="true" data-side-pagination="client" data-pagination="false" data-filter-control="true" data-id-field="COR01_ID" data-height="500" data-editable-emptytext="Empty" data-editable-url="updateField.php">
                        <thead>
                            <tr>
                                <th data-field="COR01_SEQUENCIA" data-filter-control="input" data-editable="false">SEQ</th>
                                <th data-field="DATA"  data-filter-control="input" data-editable="true"> 
                                    DATE
                                </th>
                                <th data-field="COR01_PLANT_ORDER" data-filter-control="input" data-editable="false">PO</th>
                                <th data-field="COR61_COD_MATERIAL" data-filter-control="input" data-editable="false">Code</th>
                            </tr>
                        </thead>
                    </table>

I try put data-editable-validate, data-validate and nothing work. How can I validade the value after edit??

I try validate in server side and response a string with the error but I can show this error because I dont have a callback to get it. How can I do this too?

All 8 comments

You can simulate a callback using myjson.com. Setup a JSFiddle so people can help you.

Sorry.
https://jsfiddle.net/4200stke/2/

On the code, how can I validate the new value?
I try the "data-editable-validate" calling a function but it isnt work

The last time I used that function, I had about 30 columns to validate so I defined a typical column like this

{ field: 'Price', title: 'Price', class: 'danger',editable: { mode: 'inline', validate: function (v) { return validateData(this, v); }, }, },

The validateData function was called for all data changes.

First I get the name of the field , then use the if/then to validate.

    function validateData(t, v) {
        name = $(t).data("name");

var priceMax = 1000;
// console.log(name);
if (name=='Price' && v>priceMax) {
return 'You must enter a price less that ' + priceMax;
}else{
return '';
}

Looks like it come from the plugin - see this example for more info

I thought the data-editable-validate needed to be on the th tag, not the table itself, but this also doesn't seem to be the case based on the JSFiddle I've created.

https://jsfiddle.net/4200stke/11/

Can anyone clarify?

I had a complex form with lots of validation - I did this for the editable settings

editable: { mode: 'inline', validate: function (v) { return validateData(this, v); }, }, },

The validateData was my function to look at the field to be validated and apply the proper rules. I think returning false cancels the edit.

Full field definition:

*

  { field: 'aimValue', title: 'Aim<br>Value', class: 'danger',editable: { mode: 'inline', validate: function (v) { return validateData(this, v); }, }, },

Hi! We don't have any reply in that case we are going to close this issue. If the issue is still present please open a new Issue or PR with an example. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

thibaultvanc picture thibaultvanc  路  20Comments

wenzhixin picture wenzhixin  路  35Comments

iamthestreets picture iamthestreets  路  26Comments

havok2063 picture havok2063  路  39Comments

typo3ua picture typo3ua  路  23Comments