Edits With Same Controller But Different Editors Not Working
Edits With Same Controller But Different Editors Not Working
Hi,
Kindly help with the following:
I have a controller which is accessed from two different views. The editor in the first one is allowed to edit some fields whiles the second can modify all fields.
My issue is that edits from the first view works fine but not the second. They both do not return any errors. The Controller and the Form Data for first and second interfaces are shown below:
Controller:
var formData = HttpContext.ApplicationInstance.Context.Request;
var settings = iSource_Editor.Properties.Settings.Default;
using (var db = new Database(settings.DbType, settings.DbConnection))
{
int Vendor_ID = User_ID;
string Vendor_ID_Operator = "=";
string User_Type = (string)Session["UserType"];
if (User_Type.Equals("Sourcing"))
{
Vendor_ID = 0;
Vendor_ID_Operator = ">";
}
Editor editor = new Editor(db, "Vendor", "ID")
.Model<Vendor>("Vendor")
.Where("ID", Vendor_ID, Vendor_ID_Operator)
.Field(new Field("Reset_Password").Set(Field.SetType.Create).SetValue(1))
.Field(new Field("CreatedBy").Set(Field.SetType.Create).SetValue(Vendor_ID))
.Field(new Field("CreatedDate")
.Set(Field.SetType.Create).SetValue(DateTime.Now)
.GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
.SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
)
.Field(new Field("ModifiedBy").Set(Field.SetType.Both).SetValue(Vendor_ID))
.Field(new Field("ModifiedDate")
.Set(Field.SetType.Both).SetValue(DateTime.Now)
.GetFormatter(Format.DateSqlToFormat(Format.DATE_ISO_8601))
.SetFormatter(Format.DateFormatToSql(Format.DATE_ISO_8601))
)
//TO DO: TO REMOVE .Debug(true) LINE AFTER DEBUGGING
.Debug(true);
//Return response to view
DtResponse response = editor.Process(formData).Data();
return Json(response, JsonRequestBehavior.AllowGet);
}
Form Data - First Interface:
data%5Brow_2359%5D%5BVendor%5D%5BUsername%5D=HOL&data%5Brow_2359%5D%5BVendor%5D%5BName%5D=Holman+Consulting+Ltd&data%5Brow_2359%5D%5BVendor%5D%5BContact_Person_Email_address%5D=stephen.amevedzi%40gmail.com&data%5Brow_2359%5D%5BVendor%5D%5BActive%5D=true&action=edit
Form Data - Second Interface:
data%5Bkeyless%5D%5BVendor%5D%5BTitle%5D=0&data%5Bkeyless%5D%5BVendor%5D%5BName%5D=Holman+Consulting+Ltd&data%5Bkeyless%5D%5BVendor%5D%5BPhysical_Address%5D=1st+Floor+Maxsony+Plaza%2C+No+37+Okodan+Street+Osu&data%5Bkeyless%5D%5BVendor%5D%5BPostal_Address%5D=LG+29+Legon&data%5Bkeyless%5D%5BVendor%5D%5BTelephone%5D=0246143912++++&data%5Bkeyless%5D%5BVendor%5D%5BFax%5D=1234567890&data%5Bkeyless%5D%5BVendor%5D%5BContact_Person%5D=Kobina+Holman&data%5Bkeyless%5D%5BVendor%5D%5BContact_Person_Telephone%5D=0246143912&data%5Bkeyless%5D%5BVendor%5D%5BContact_Person_Email_address%5D=stephen.amevedzi%40gmail.com+&data%5Bkeyless%5D%5BVendor%5D%5BWeb_address%5D=www.holmanconsultinggh.com&data%5Bkeyless%5D%5BVendor%5D%5BNature_of_Business%5D=1&data%5Bkeyless%5D%5BVendor%5D%5BBusiness_type%5D=3&data%5Bkeyless%5D%5BVendor%5D%5BTax_Number%5D=C0061005789&data%5Bkeyless%5D%5BVendor%5D%5BRegistration%5D=BNOOZMB2015&data%5Bkeyless%5D%5BVendor%5D%5BRegistration_Date%5D=23%2F09%2F2015+12%3A00%3A00+pm&data%5Bkeyless%5D%5BVendor%5D%5BBankID%5D=20&data%5Bkeyless%5D%5BVendor%5D%5BBankBranchID%5D=1044&data%5Bkeyless%5D%5BVendor%5D%5BBanck_Account_Number%5D=201110439140&data%5Bkeyless%5D%5BVendor%5D%5BBank_Account_Name%5D=+HOLMAN+CONSULTING&data%5Bkeyless%5D%5BVendor%5D%5BGSB_Conform%5D=2&data%5Bkeyless%5D%5BVendor%5D%5BIQS_Conform%5D=2&data%5Bkeyless%5D%5BVendor%5D%5BWorking_Hours%5D=8am+-+5pm&action=edit
Thanks in advance,
---Stephen
Replies
That suggests to me that the non-working table doesn't have the ID information. Is it a DataTable that you are editing data in on that one? If so, can you show me the configuration you are using for the DataTable and also the JSON response from the server for loading the data?
Thanks,
Allan
Hi Allan,
Thanks for the quick response.
The final solution does not use a DataTable but I tried that as well but same problem.
When the page loads, we pick the profile details of the vendor who has logged in and present in a panel using the Panel Creation Function. When the vendor clicks on the edit button, we call up the editor. The various code scrips are below.
Panel Creation Function
Thanks,
---Stephen
The other scripts are as follows:
Ajax To Load Vendor Profile
On Panel Button Click
Editor:
Please, can you also suggest a better way, if there is one, to get this done.
Thanks,
---Stephen
But:
That case difference might be the issue. I've just tried a little experiment and it does appear to make a difference:
Allan
Hi Allan,
Thanks once again for the response.
I am happy to inform that I have tried your suggestion and it worked.
Unfortunately, I have an associated issue coming up. The delete button of the DataTable below the Panel does not work most of the time. The delete confirmation window pops up but when you click on the 'Delete' button at the button right of the window, no action happens. The associates scripts are below.
Thanks,
---Stephen
Hi Stephen,
Is the Ajax request to the server for the delete action made? You'd be able to see it in the browsers "Network" inspector panel.
I think I'd need a link to your page to be able to help debug this one fully.
Allan
Hi Allan,
Thanks for the response once again.
No, the Ajax request to the server for the delete action is not made at all.
I have also noticed that the DataTable loads with a default value in the search box which filters the DataTable ones it loads. The following is the screenshot (https://datatables.net/forums/uploads/editor/8q/brr017bqxqmh.png ""). Could this be a factor? How do I take it out?
The app is offline now. Would you want to come in remotely?
Thanks,
---Stephen
There is nothing in the code above that would cause a default search value. Perhaps you have state saving enabled somewhere? That shouldn't cause any issues with the delete submission though.
You are using
preSubmit
- my guess is that the event is returningfalse
for theremove
action. Try adding:at the top of that function.
Allan
Hi Allan,
I'm happy to inform you that your suggestion worked.
Also, the default filtering was happening because of saved passwords; once I removed the saved passwords, the filtering stopped.
Thanks so much for your assistance.
---Stephen