Don't need to insert on left join table
Don't need to insert on left join table
I am using a left join just to show a value on the parent table. when I do an insert on the parent table, however, editor is trying to insert on the left join table as well.
I tried .set(false) on all the fields on the left join but that didn't seem to help
when doing an insert where a leftJoin exists, is there a way for the edit/insert only to happen on the 'main' table (JobTitles in this case.
public class JobTitlesController : ApiController
{
[Route("api/JobTitles")]
[HttpGet]
[HttpPost]
public IHttpActionResult JobTitles()
{
var request = HttpContext.Current.Request;
var settings = Properties.Settings.Default;
var AsOfCookie = request.Cookies.Get("AsOfDate").Value;
using (var db = new Database(settings.DbType, settings.DbConnection))
{
var response = new Editor(db, "JobTitles", "JobTitleID")
.Model<JobTitlesModel>("JobTitles")
.LeftJoin("JobTitleRates", "JobTitles.JobTitleID", "="
, "JobTitleRates.JobTitleID and '" + AsOfCookie + "' Between JobTitleRates.EffectiveDate and isnull(JobTitleRates.ExpireDate,getdate())")
.Field(new Field("JobTitleRates.HourlyRate").Set(false))
.Field(new Field("JobTitleRates.JobTitleID").Set(false))
.Field(new Field("JobTitleRates.JobTitleRateID").Set(false))
.Field(new Field("JobTitleRates.EffectiveDate").Set(false))
.Field(new Field("JobTitleRates.ExpireDate").Set(false))
.Process(request)
.Data();
return Json(response);
}
}
}
This question has an accepted answers - jump to answer
Answers
Does your client-side Editor have any fields configured for the joined table - e.g.
JobTitleRates.HourlyRate
or something like that?Allan
no, just the one field, jobTitle.
How odd! I don't have an immediate answer for this I'm afraid. Could you change:
to be:
And then try inserting a row while your browser's Network inspector is open and then copy / paste the JSON response from the server so I can see what is happening please?
Thanks,
Allan
odd...debug seems to return null??
ah, the .Debug(true) needs to be before the .Process(request)
here you go...
and here is the debug when I get rid of the left join table:
Is
JobTitleID
an auto incrementing column?Also is
JobTitleID
in your model for theJobTitles
table? If so add:just after your
.Model(...)
call.Allan
yes, it is an auto increment id field. The insert record works fine when I get rid of the left join.
However, I tried adding the line you mentioned above and I still got the error:
which, if it is talking about the key in the left joined table is JobTitleRateID, which I already have .Set(false).
Apologies - I missed before that you had a Join condition more complex than normal. Could you use:
The problem with it as it was before was that the "value" part would have been "bound" stopping it from working.
Is that the only issue? I'm not certain! If it doesn't fix it - could you add
.TryCatch(false)
just before the.Debug(true)
line and that should give us a bit more information when it errors out.Thanks,
Allan
When I use the syntax you provided above I get the error
here is the information from the trycatch (using my original LeftJoin statement):
What version of the DataTables.dll are you using? The error:
Suggests you might be using one from before v2.0.0? This is the commit that added support for complex joins in DataTables.dll and it landed for v2.0.0.
Regards,
Allan
ah, yes, I have not upgraded to 2.0 yet.
I just did the upgrade to 2.0.4 and I am not getting an error on the .LeftJoin.
However, none of the dataTables on my pages load anymore. I am getting the error:
I brought in the correct dll, and have the correct .js and .css files (as far as I can see).
Apologies - a string split which isn't available in all builds of .NET slipped into our last release!
The latest dll with the fix can be downloaded here.
Allan
now i am getting the error:
which i see has been reported before as an issue with SearchPane library?? what do i need to do to resolve this error?
Seems like you are referring to this thread. Make sure you are running SearchPanes 1.2.1 or later. I think its at 1.3.0 now. I would load the latest. IIRC that error occurs when loading the SearchPanes library but not enabling it.
Kevin
uh oh, I have one main page that has all of my js and css includes. Then, I load all the dataTables into a div of that main page depending what they select from the top navigation. Not all the dataTables have searchPanes, but many do. And, I can have several dataTables on one page with some of them not having searchPanes but others on that same page would.
i uploaded my configuration data to debug.datatables.net. the code is: abaxox
I used the Generator tool to create the js files after I upgraded to 2.0.4
I'm not a Datatables employee so don't have access to the debug trace. Does the error occur on every Datatable or just the one's without SearchPanes? It could be a different problem. Please provide more details or maybe a link to the page with the error.
Kevin
i just realized I didn't grab the latest searchPanes and such, so I just updated to this:
But now I am getting a different error:
I changed it back to my previous code and updated only searchPanes to 1.3.0. I am not getting the 'indexOf' error, but back to that 'rebuild' error.
interesting..i get the indexOf when I change from jqc-1.12.4 to jq-3.3.1
1.12.4 works where 3.3.1 does not
ah, I see, I still had a seperate reference to Searchpanes in my html
ok. all is good in the world of DataTables now.
The insert is working with the complex leftJoin.