PDA

View Full Version : Can we hide checkbox(via CheckBoxCell) for special rows in the grid with InlineEdr?



LoriSun
18 Mar 2012, 7:34 PM
Hi Dev,

Can we hide the special row's checkbox for grid which has one column with CheckBoxCell?
I have tried with the approach: cell.removeFromParent(), it works at the initial time, but my grid also has inline editing feature, after the editing.onCompleteEdit(....) , the checkbox of the current editing row was back again. :-/

Do you guys have any good approach? Could you please share.

Thanks in advance
Lori

LoriSun
19 Mar 2012, 5:47 PM
Hi support,

Could you please advise? or GXT doesn't have such feature now.....:)

Thanks,
Lori

LoriSun
19 Mar 2012, 10:52 PM
Hi Guys,

I got a strange approach, use the value of CheckBoxCell column( true -> checked; false -> unchecked; null -> hidden )
it really works for me.:D share as below:

We need 2 classes modified.

1,) CheckBoxDefaultAppearance4Hidden :


public class CheckBoxDefaultAppearance4Hidden extends CheckBoxDefaultAppearance {

@Override
public void render( SafeHtmlBuilder sb, Boolean value, CheckBoxCellOptions options ) {
String name = options.getName() != null ? " name='" + options.getName() + "' " : "";
String disabled = options.isDisabled() ? " disabled=true" : "";
String ro = options.isReadonly() ? " readonly" : "";
String id = " id=" + XDOM.getUniqueId();
String t = " type=" + type;
sb.appendHtmlConstant( "<div class=" + style.wrap() + ">" );
if ( value != null ) {
String checked = value ? " checked" : "";
sb.appendHtmlConstant( "<input " + t + name + disabled + ro + id + checked + "/>" );
}else {
sb.appendHtmlConstant( "<span " + name + id + "/>" );
}
sb.appendHtmlConstant( "<label for=" + id + " htmlFor=" + id + " class=" + style.checkBoxLabel() + ">" );
if ( options.getBoxLabel() != null ) {
sb.appendHtmlConstant( options.getBoxLabel() );
}
sb.appendHtmlConstant( "</label>" );

}
}


2,) CheckBoxCell4Hidden :


public class CheckBoxCell4Hidden extends CheckBoxCell {

public CheckBoxCell4Hidden( CheckBoxAppearance appearance ) {
super( appearance );
}

@Override
public void render( com.google.gwt.cell.client.Cell.Context context, Boolean value, SafeHtmlBuilder sb ) {
CheckBoxCellOptions opts = new CheckBoxCellOptions();
opts.setName( name );
opts.setReadonly( isReadOnly() );
opts.setDisabled( isDisabled() );
opts.setBoxLabel( getBoxLabel() );

//appearance.render(sb, value == null ? false : value, opts);
//pass 'null' as a validated value
appearance.render( sb, value, opts );
}
}


Useage:


private final ColumnConfig<PreNameValue4Gride, Boolean> cc2 = new ColumnConfig<PreNameValue4Gride, Boolean>(roperties.willBeDeleted(),35, "" );

CheckBoxCell cbc = new CheckBoxCell4Hidden( new CheckBoxDefaultAppearance4Hidden() );

cc2.setCell( cbc );



If any formal /good approach, please let me know.

Thanks,
Lori

mtduit
17 Jan 2013, 7:29 PM
Hi. You can try codes:
getDisplay().getGridConfig().getView()
.getCell(3, 0).<XElement> cast()
.selectNode("input")
.setAttribute("disabled", "disabled");