Quantcast
Channel: DataTables 1.10 — DataTables forums
Viewing all articles
Browse latest Browse all 2364

Updating 2nd table via a leftjoin

$
0
0

Link to test case:
Debugger code (debug.datatables.net):
Error messages shown:
Description of problem: Trying to work around issue given on https://datatables.net/forums/discussion/comment/152200/#Comment_152200. I have also 2 tables but only the 2nd table needs to have a row inserted with the 1st table's id. The 1st table is there just to show its data. User has to enter a value for rows from 1st table and 2nd table gets a field set with the 1st table's row id. Issue I have is the insert never happens. PostCreate line never gets triggered either. Here's my code:
`using (Database db = new Database(SetGetDbType2, SetGetDbConnection))
{
editor = new Editor(db, "Csp", "Csp.id").Model<myDBModel.Csp>("Csp");
editor.Field(new Field("Csp.id")
.Set(false)
);

                editor.Field(new Field("Csp.CustomerID")
                    .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? 0 : val)
                    .Set(false)
                );
                editor.Field(new Field("Csp.Name")
                    .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? string.Empty : val)
                    .Set(false)
                );
                editor.Field(new Field("Csp.Description")
                    .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? string.Empty : val)
                    .Set(false)
                );
                editor.Field(new Field("CspRelations.ParamType")
                    .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? 0 : val)
                    .Set(false)
                );

                editor.Field(new Field("Dc.DistributorID")
                    .SetValue(lngDistIdx)
                );
                editor.Field(new Field("Dc.CustomerID")
                    .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? 0 : val)
                    .SetValue(lngCustIdx)
                );
                editor.Field(new Field("Dc.CoMmsiD")
                    .SetValue(lngSubPackIdx)
                );
                editor.Field(new Field("Dc.CoMmsComm")
                    .GetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? 0 : val)
                    .SetFormatter((val, data) => CommonUtilities.IsNullOrEmpty(val) == true ? 0 : val)
                );

                editor.LeftJoin("Dc", "Csp.id", "=", "Dc.CoMmsiD");
                editor.LeftJoin("CspRelations", "Csp.id", "=", "CspRelations.SubPackID");

                Task t;
                editor.PostCreate += (sender, e) => t = Task.Run(() => UserFilesModel.Update(6, e.Values));

                editor.TryCatch(false);
                editor.Debug(true);
                editor.Process(formData);
            }`

Dc is 2nd table, Csp is 1st table


Viewing all articles
Browse latest Browse all 2364

Trending Articles