Editor Inline, input sent empty even he has value in first on edit
Editor Inline, input sent empty even he has value in first on edit
Editor Inline, input sent empty even he has value before edit
this wired because i have the same table but with diffrent parmas in other view that working fine with editor inline
in this view when i want to edit, Air_Fare_T.AirFare_Code_T always sent empty on inline edit
i have this serverSide code:
[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public ActionResult GetDataAirFareTrip(int id)
{
var settings = Properties.Settings.Default;
var formData = HttpContext.ApplicationInstance.Context.Request;
using (var db = new DataTables.Database(settings.DbType, settings.DbConnection))
{
var editor = new DataTables.Editor(db, "Air_Fare_T", "Air_Fare_T_Id");
editor.Where(q =>
q.Where("Air_Fare_T.AirFare_Costing_T_Id", "(SELECT AirFare_Costing_T_Id FROM Air_Fare_T WHERE AirFare_Costing_T_Id= " + id + ")", "IN", false)
);
editor.Model<ViewModel.AirFareTripEditorVM>("Air_Fare_T")
.Field(new Field("Air_Fare_T.Air_Fare_T_Id")
.Validator(Validation.Numeric())
.Set(false)
)
.Field(new Field("Air_Fare_T.AirFare_Costing_T_Id")
.Validator(Validation.Numeric())
)
.Field(new Field("Air_Fare_T.AirFare_Code_T").Xss(true)
.Validator(Validation.Numeric())
.SetFormatter(Format.IfEmpty(null))
)
.Field(new Field("Air_Fare_T.Air_Fare_T_Type").Xss(true)
.Validator(Validation.Numeric())
.Options(new Options()
.Table("AirFare_Trip_Type")
.Value("AirFare_Trip_Type_Id")
.Order("AirFare_Trip_Type.AirFare_Trip_Type_Id")
.Label("AirFare_Trip_Type_Name")
)
.SetFormatter(Format.IfEmpty(null))
)
.Field(new Field("Air_Fare_T.Air_Fare_T_Currency").Xss(true)
.Validator(Validation.Numeric())
.Options(new Options()
.Table("CurrencyCosting")
.Value("Currency_Id")
.Order("CurrencyCosting.Currency_Id")
.Label("Currency_Name")
)
.SetFormatter(Format.IfEmpty(null)))
.Field(new Field("Air_Fare_T.Air_Fare_T_Price").Xss(true)
.Validator(Validation.Numeric())
.SetFormatter(Format.IfEmpty(null)))
.Field(new Field("Air_Fare_T.Air_Fare_T_PAX").Xss(true)
.Validator(Validation.Numeric())
.SetFormatter(Format.IfEmpty(null)))
.Field(new Field("Air_Fare_T.Air_Fare_T_Total").Xss(true)
.Validator(Validation.Numeric())
.SetFormatter(Format.IfEmpty(null)));
editor.Model<ViewModel.CostingAirlineEditorVM>("Costing_Airlines")
.LeftJoin("Costing_Airlines", "Costing_Airlines.Airline_Id", "=", "Air_Fare_T.AirFare_Code_T");
editor.Model<ViewModel.AirFareTripTypeEditorVM>("AirFare_Trip_Type")
.LeftJoin("AirFare_Trip_Type", "AirFare_Trip_Type.AirFare_Trip_Type_Id", "=", "Air_Fare_T.Air_Fare_T_Type");
editor.Model<ViewModel.CurrencyCostingEditorVM>("CurrencyCosting")
.LeftJoin("CurrencyCosting", "CurrencyCosting.Currency_Id", "=", "Air_Fare_T.Air_Fare_T_Currency");
// Post functions
editor.PreCreate += (sender, e) =>
{
var totalVal = getTotalValTrip(e.Values, id);
editor.Field("Air_Fare_T.Air_Fare_T_Total").SetValue(totalVal[1]);
editor.Field("Air_Fare_T.Air_Fare_T_Price").SetValue(totalVal[0]);
};
editor.PreEdit += (sender, e) =>
{
var totalVal = getTotalValTrip(e.Values, id);
editor.Field("Air_Fare_T.Air_Fare_T_Total").SetValue(totalVal[1]);
editor.Field("Air_Fare_T.Air_Fare_T_Price").SetValue(totalVal[0]);
};
editor.Process(formData.Unvalidated.Form);
DtResponse data = editor.Data();
return Json(data, JsonRequestBehavior.AllowGet);
}
}
This question has accepted answers - jump to:
This discussion has been closed.
Answers
this is the view code:
Hi,
Don't combine:
with:
Drop the second block - let KeyTable handle the inline editing itself. If you want
allIfChanged
add:to your Editor initialisation object.
Regards,
Allan
hey Allan, thanks for the replay
i change as you recommend, but still its not working
If you could give me a link to the page I'll debug it directly.
Thanks,
Allan
hey Allen, i think i figure out what happens , if i use allIfChanged in submit this is delete the selected2 ajax remote value, if i cancel this it work.
what to do? i must get 3 field when one field is changed ?
to make some field-total field calculation
Please link to the page as Allan suggested, then we can take a look.
Colin
on the airFare table, you can show if you will update one filed inline the airline company will be remove!
please check it asap, thank
i send link in p.m to allan thank
Thanks for the link.
Yes - that is correct. Editor requires you to return the full data for the row in the same format that was used to load the row originally (which allows for server computed fields).
Regarding the link - now that I've made an edit, how do I reassign a valid code for the air fare? It disappeared as you said, and I expected it to appear again on reload, but that isn't the case. So I'm not sure how to add it back in?
Thanks,
Allan
hey allan, you need to delete and add new one
i add 3 new row, you can play witj
i must say that when you change something in this row, it make calculation and i check always the air fare id come empty without value, so even if you refresh the page it will stay empty
hey Allan i have more question, how i can make editor options where to check if id is in list<int>, and that where will happen only on specific condition?
Thanks for adding those rows. The problem relates to the value not being present in the Select2 field for the
AirFare_Code
.When you trigger editing on a cell, an Ajax request is sent to the server:
That happens for Select2 fields so you can respond with the value and label option that should be shown in the field - e.g.
[{label: "ISS", value: 3563}]
. However, currently that script is just responding with[]
. Thus the Select2 field doesn't have a value and when the form is submitted it has an empty value sent for that field.You need to change
getAirLineCodes
to handle thatinitialValue
request. Or if you don't want that field to be editable, remove it from the Editor fields.Do you mean as a validator? You would need a custom validator.
Allan
"You need to change getAirLineCodes to handle that initialValue request. Or if you don't want that field to be editable, remove it from the Editor fields."
allan if i remove this form editor field, i cannot create new row with this field
no option just on edit not include this field?
Ah okay - the easiest way to handle this then is going to be to add:
for the
Field
in your C# code.That will result in the value being written to the database only on create, and ignored on edit.
Alternatively, you could use
initCreate
andsubmitComplete
to add and remove the field from the field list, but I think theSet()
method is more secure (and easier).Allan
hey allan,
.Set(Field.SetType.Create)
worked wall, but if i want the to have validation on input in create mode it will work, but if i will try to edit inline, i will always get the required message for this field
how i can make this work?
i also changed the code in getAirLineCodes to handle with initialValue request
its worked and return the right option but still the field submit without value form inline edit
even if i try to edit regular not with inline, the select list empty
Sounds like you might have some validation on the field which is marking it as required, even on edit?
I'd suggest using your
PreCreate
event handler to add the validation for this field. That way it will validate on create only, not edit.Allan
hey allan i resolve this problem, its sound stupid, but initialValue need to return list with text and id in small latter, if initalValue value is empty you need to return list of Name and Id.
i have another question about editor date-time field, i want that if i will chose start date value the end date windows(not value) will open in the same month of the start date,
i know i need to used dependent but i cant think about way to get and changed the initialize windows date of end date field