MJoin Help
MJoin Help
Hello all,
I have been trying to work on an MJoin link without much success any help would be appreciated.
First the tables are as seen below:
1.) (SaMainRec) contains entities that may have one or more address
2.) saCompToAdd is the linking table has SaMainRec PK and SaAddress PK
3.) SaAddress has many adresses that could be link to one or many Records
My Controller Code:
using (var db = new Database(settings.DbType, settings.DbConnection))
{
var response = new Editor(db, "SaAddress", "saAddID")
.Debug(true)
.Model<SaAddress>()
.Field(new Field("AddressLabel")
.Validator(Validation.NotEmpty())
)
.Field(new Field("Address1")
.Validator(Validation.NotEmpty())
)
.Field(new Field("City")
.Validator(Validation.NotEmpty())
)
.Field(new Field("State")
.Validator(Validation.NotEmpty())
)
.Field(new Field("Country")
.Validator(Validation.NotEmpty())
)
.Field(new Field("ZipCode")
.Validator(Validation.NotEmpty())
)
.MJoin(new MJoin("SaMainRec")
.Link("SaAddress.SaAddID", "SaCompToAddress.SaAddID")
.Link("SaMainRec.SalesOpID", "SaCompToAddress.SalesOpID")
.Model<SaCompToAddModel>()
.Field(new Field("SalesOpID")
.Options(new Options()
.Table("SaMainRec")
.Value("SalesOpID")
.Label("CompanyName")
)
)
.Field(new Field("CompanyName"))
)
.Process(Request.Form)
.Data();
return Json(response, JsonRequestBehavior.AllowGet);
Javascript code: (Editor initialization)
var AddressEditor = new $.fn.dataTable.Editor({
ajax: "/CRM/SavAddress",
template: "#AddressForm",
"idSrc": 'saAddID',
fields: [
{
label: "Tag (Desc)",
name: "AddressLabel",
}
, {
label: "Address:",
name: "Address1"
}, {
label: "City:",
name: "City"
},
{
label: "State:",
name: "State"
},
{
label: "Zip:",
name: "ZipCode"
},
{
label: "Country:",
name: "Country"
}, {
label: "Notes:",
name: "AddNotes",
'type': 'textarea',
className: 'block'
},
//}, {
// type: "hidden",
// name: "SalesOpID"
//},
{
"label": "Company To Link:",
"name": "SaMainRec[].SalesOpID",
"type": "select",
"multiple":"true"
}
]
});
Html code ( As I am using a template for the form):
Finally how the editor form appears.:
So as you can see the Select is not populating and the results if submitted without the selects produces another error:
Answers
Hi,
Can you use the debugger to give me a trace please - click the Upload button and then let me know what the debug code is.
Allan
Hello Allan,
Thank you for taking the time to reply.
I have uploaded the debugger, I apologized as I had code that should have been commented out when I first ran the debugger, and I may I uploaded the wrong version a couple times. I held back from running a third time to avoid filling up the debugger with garbage.
Please let me know if I should run again I clear up the extras and now got a clearer picture.
Could you let me know the six letter debug code? You might need to run the debugger again to get a new code.
Thanks,
Allan