on 09-19-2016 12:39 PM
Hi Everyone.
i am developing SAPUI5 application using UI5 tables.i need to disable cell which is having values through javascript method,
screenshot from SAP standard screen. as like above table i need to disable some cells depends on the value.
can any one help me to find out the solution?
Thanks,
Ranjani Sekar.
Thank You All,
now its working as i expected. i have used below in View.js and i didn't write any method in controller.
oUOMTable.addColumn(new sap.ui.table.Column({
label : new sap.ui.commons.Label({
text : "Alt. UOM" }),
template : new sap.ui.commons.ValueHelpField({maxLength:3 ,
editable:{
path: 'Meinh',
formatter: function(Meinh){
if (Meinh != null || Meinh ==''){return false;}
else{return true;}
}},
}).bindProperty("value", "Meinh"),
sortProperty : "Meinh",
filterProperty : "Meinh",
width : "90px",
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Ranjani,
you can use below code also while defining input in to the table cell:
// input will be editable if value2 = X
<Input text="{value1}" editable="{= ${value2} == 'X' ? true : false}" />
Regards,
Akhilesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Assuming you are using sap.m.Input as template for the column you want to disable, you can format property "editable" of the control:
<Input
value="{b}"
editable="{path: 'a', formatter: '.editableFormatter'}" />
in the controller:
editableFormatter: function (value) {
if (value === 'editable') {
return true;
} else {
return false;
}
}
Here a jsfiddle:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Francesco,
thank you for your reply. i am using Value help field so couldn't use editableFormatter method. but i have tried with this and no effect in screen.
above is my code in view.js page. on binding values to this table i need to disable this cell if it having value. if value is blank then it should be enable to enter value.
kindly give me your suggestion.
Thanks,
Ranjani Sekar.
Hi Sekar,
sap.ui.commons.ValueHelpField extends TextField that has editable property, you can use formatter on it:
You might want to use a custom formatter function.
Here is an example of how your problem may be solved:
View:
<Table id="table">
<columns>
<Column/>
<Column/>
</columns>
</Table>
Controller:
onAfterRendering: function(){
var oData = {data: [
{cell1: 1, cell2: "disabled"},
{cell1: 2, cell2: "enabled"},
{cell1: 1, cell2: "disabled"},
{cell1: 1, cell2: "disabled"},
{cell1: 2, cell2: "enabled"}
]};
this.getView().setModel(new sap.ui.model.json.JSONModel(oData), "model");
var oTable = this.getView().byId(this.createId("table"));
oTable.bindAggregation("items", "model>/data", new sap.m.ColumnListItem({
cells:[
new sap.m.Label({
text: "{model>cell1}"
}),
new sap.m.Input({
value: "{model>cell2}",
enabled: {
path: "model>cell1",
formatter: function(cell1){
if(cell1 === 1){return false}
else {return true}
}
}
}),
]
}))
}
Here is a working example:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.