Apr 23, 2009, 12:15 PM
Editor cell shapeShifter
Hi,
I am trying to do something weird.
I have a gridpanel that contains something like this :
Property Value Unit
------------- ---------- --------
IP 12.23.35.156 IP
Brand Tipco Brand
Nb 3 Int
I want to edit the IP value. I want my field to be a textField with an IP regex validation.
I want to edit the Brand value. I want my field to be a combobox with a list of Brands.
I want to edit the number value. I want my field to be a TextField with an int maskRe.
With the following code, I get :
I edit the IP value first, my field is an "IP field" but then when I edit the brand field, the event is fired but the trigger does not appear.
When I edit the Brand value first, my field is an "Brand field" and the store loaded but then when I edit the IP value, the tigger does not disappear.
How is it possible make things right ?
Here is the code :
In the value column :
Thank you.
BrunoC
I am trying to do something weird.
I have a gridpanel that contains something like this :
Property Value Unit
------------- ---------- --------
IP 12.23.35.156 IP
Brand Tipco Brand
Nb 3 Int
I want to edit the IP value. I want my field to be a textField with an IP regex validation.
I want to edit the Brand value. I want my field to be a combobox with a list of Brands.
I want to edit the number value. I want my field to be a TextField with an int maskRe.
With the following code, I get :
I edit the IP value first, my field is an "IP field" but then when I edit the brand field, the event is fired but the trigger does not appear.
When I edit the Brand value first, my field is an "Brand field" and the store loaded but then when I edit the IP value, the tigger does not disappear.
How is it possible make things right ?
Here is the code :
In the value column :
<Editor>
<ext:ComboBox ID="ddlModif" runat="server"
StoreID="stoModif"
DisplayField="Text"
ValueField="Value"
Mode="Local"
RegexText="Incorrect Format"
MaxLengthText="Max Length reached">
</ext:ComboBox>
</Editor>
In the gripPanel :<Listeners>
<BeforeEdit Handler="ChargeType('ddlModif',grdModif.store.getById(#{grdCaracModif}.getSelections()[0].id).get('Unit'));" />
</Listeners>
The store :<ext:Store ID="stoModifCarac" runat="server" AutoLoad="false" IgnoreExtraFields="true">
<Proxy>
<ext:HttpProxy Method="GET"/>
</Proxy>
<Reader>
<ext:JsonReader Root="Datas" TotalProperty="Total">
<Fields>
<ext:RecordField Name="Text"/>
<ext:RecordField Name="Value"/>
</Fields>
</ext:JsonReader>
</Reader>
</ext:Store>
The ChangeType function :ChargeType = function(id, unit) {
var field = Ext.getCmp(id);
var load = false;
if (field) {
//ShapeShifting
switch(unit) {
case 'IP':
field.hideTrigger = true;
field.editable = true;
field.maskRe = /[0-9.]/;
field.regex = /^([1-9][0-9]{0,1}|1[013-9][0-9]|12[0-689]|2[01][0-9]|22[0-3])([.]([1-9]{0,1}[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])){2}[.]([1-9][0-9]{0,1}|1[0-9]{2}|2[0-4][0-9]|25[0-4])$/;
field.maxLength = 15;
break;
case 'Brand':
field.hideTrigger = false;
field.editable = true;
field.maskRe = null;
field.regex = null;
field.maxLength = 40;
load = true;
break;
case 'Int':
field.hideTrigger = true;
field.editable = true;
field.maskRe = /[0-9]/;
field.regex = null;
field.maxLength = 10;
break;
default:
field.hideTrigger = true;
field.editable = true;
field.maskRe = null;
field.regex = null;
field.maxLength = 10;
break;
}
if (load == true) {
//Chargement du store
champ.store.load({
params:{
unit:unit
}
});
}
}
}
}
Thank you.
BrunoC