kenxran / jquery-datatables-editable

Automatically exported from code.google.com/p/jquery-datatables-editable
0 stars 0 forks source link

Refresh the whole table after adding a new record. #101

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I'm try to use jquery-datatables-editable. It's work but not 100% precent. 
If i adding a new record it's not refreshing! After i refresh the whole site 
it's correct.

1. i push the add button
2. i add new the new datas
3. i click ok
4. NOTHING, after i refresh i can see the new data.

What should i do?

THX

Original issue reported on code.google.com by mihaly.h...@gmail.com on 17 Mar 2012 at 7:03

GoogleCodeExporter commented 9 years ago
Hi,

I cannot help you without more data. Do you have the latest version of plugin, 
are there any Javacript error, Do you see some error in firebug, does the ajax 
call fail?

Jovan

Original comment by joc...@gmail.com on 17 Mar 2012 at 10:40

GoogleCodeExporter commented 9 years ago
Hello!

version 1.3
No erros with firebug.
Ajax call works fine (Becouse i can see all data).

THX

Original comment by mihaly.h...@gmail.com on 18 Mar 2012 at 9:05

GoogleCodeExporter commented 9 years ago
Hi!

I am seeing the same issue, except I get an error: 'DataTables warning (table 
id = 'DataTables_Table_0'): Requested unknown parameter '1' from the data 
source for row 169'.
ID is returned correctly via AJAX-Call.

What can cause the problem?

Original comment by l.szlac...@gotomedia.de on 5 Apr 2012 at 8:35

GoogleCodeExporter commented 9 years ago
The same issue here... I'm using javascript array (json) data to fill my 
datatable and probably datatables-editable is not adding this new array info to 
aaData

Original comment by vitoru...@gmail.com on 10 Aug 2012 at 9:29

GoogleCodeExporter commented 9 years ago
I can't get it to refresh either. I've been searching for days for a solution 
to no avail. Seems like this is a common problem.

Original comment by Sadie.He...@gmail.com on 16 Aug 2012 at 9:51

GoogleCodeExporter commented 9 years ago
Using version 2.3.2.
got an "rowData not defined" on line 475.
seems to be linked to the refactoring (where a function 
"fnTakeRowDataFromFormElements" was created).
Shouln't the if blocks be replacted by "rtn = oTable.fnAddData(values);" ?

Original comment by jphau...@gmail.com on 24 Sep 2012 at 1:32

GoogleCodeExporter commented 9 years ago
Solution: You need the "rel"-parameter in your formAddNewRow. In the example it 
looks like:
<form id="formAddNewRow" title="Add new record">
        <label for="engine">Rendering engine</label><br />
    <input type="text" name="engine" id="name" class="required" rel="0" />
        <br />
        <label for="browser">Browser</label><br />
    <input type="text" name="browser" id="browser" rel="1" />
        <br />
        <label for="platforms">Platform(s)</label><br />
    <textarea name="platforms" id="platforms" rel="2"></textarea>
        <br />
        <label for="version">Engine version</label><br />
    <select name="version" id="version" rel="3" multiple="multiple">
                <option>1.5</option>
                <option>1.7</option>
                <option>1.8</option>
        </select>
        <br />
        <label for="grade">CSS grade</label><br />
        <input type="radio" name="grade" value="A" rel="4"> First<br>
        <input type="radio" name="grade" value="B" rel="4"> Second<br>
        <input type="radio" name="grade" value="C" checked rel="4"> Third
        <br />
</form>

If you get a warning like 'DataTables warning (table id = 
'DataTables_Table_0'): Requested unknown parameter '1' from the data source for 
row 169', then you dont have as much parameters in you AddForm then you show in 
your DataTable.
Workaround: Add hidden inputs with rel-parameter until you have the same amount 
of parameters as you show in your table.

Original comment by nosgot...@gmail.com on 4 Apr 2013 at 10:18

GoogleCodeExporter commented 9 years ago
How to add a hidden input with rel-parameter until I have the same amount of 
parameters as you show in my side.

For example, my error message = DataTables_Table_0'): Requested unknown 
parameter '1' from the data source for row 10

Original comment by f.c...@alerton.com.au on 9 Oct 2013 at 4:37

GoogleCodeExporter commented 9 years ago
Changed the fnOnRowAdded to old one:

       ///Event handler called when a new row is added and response is returned from server
    function fnOnRowAdded(data) {
        properties.fnEndProcessingMode();

        var iColumnCount = oTable.dataTableSettings[0].aoColumns.length;
        var values = new Array();

        $("input:text[rel],input:radio[rel][checked],select[rel],textarea[rel]", oAddNewRowForm).each(function () {
            var rel = $(this).attr("rel");
            //if (rel >= iColumnCount)
            if (rel > iColumnCount)
                properties.fnShowError("In the add form is placed input element with the name '" + $(this).attr("name") + "' with the 'rel' attribute that must be less than a column count - " + iColumnCount, "add");
            else
                values[rel] = this.value;
        });

        //Add values from the form into the table
        var rtn = oTable.fnAddData(values);
        var oTRAdded = oTable.fnGetNodes(rtn);
        //Apply editable plugin on the cells of the table
        fnApplyEditable(oTRAdded);
        //add id returned by server page as an TR id attribute
        properties.fnSetRowID($(oTRAdded), data);
        //Close the dialog
        oAddNewRowForm.dialog('close');
        $(oAddNewRowForm)[0].reset();
        $(".error", $(oAddNewRowForm)).html("");
    }

Original comment by orlando....@gmail.com on 1 Apr 2014 at 10:09