PDA

View Full Version : [CLOSED] Grid panel selected row cout check-MVC



matrixwebtech
Jun 10, 2014, 7:21 PM
I have a grid panel


<script>
Ext.onReady(function () {
// Ext.getCmp("btnEdit").setDisabled(true);
});
/* A header Checkbox of CheckboxSelectionModel deals with the current page only.
This override demonstrates how to take into account all the pages.
It works with local paging only. It is not going to work with remote paging.
*/
Ext.selection.CheckboxModel.override({
selectAll: function (suppressEvent) {
var me = this,
selections = me.store.getAllRange(), // instead of the getRange call
i = 0,
len = selections.length,
start = me.getSelection().length;
me.suspendChanges();
for (; i < len; i++) {
me.doSelect(selections[i], true, suppressEvent);
}
me.resumeChanges();
if (!suppressEvent) {
me.maybeFireSelectionChange(me.getSelection().leng th !== start);
}
},
deselectAll: Ext.Function.createSequence(Ext.selection.Checkbox Model.prototype.deselectAll, function () {
this.view.panel.getSelectionMemory().clearMemory() ;
}),
});
</script>




Html.X().GridPanel()
.ID("GridPanel1")
.Title("Tasks")
.Frame(true)
.Layout("fit")
.Store(
Html.X().Store()
.ID("Store1")
.Model(
Html.X().Model()
.IDProperty("MaterialCatergoryID")
.Fields(

Html.X().ModelField().Name("IsActive").Type(ModelFieldType.Boolean),

Html.X().ModelField().Name("CategoryName").Type(ModelFieldType.String)

)
)
.DataSource(ViewBag.loadgrid)
.PageSize(10)
)
.ColumnModel(
Html.X().Column()
.DataIndex("IsActive")
.Text("IsActive")
.Flex(1),
Html.X().Column()
.DataIndex("CategoryName")
.Text("CategoryName")
.Flex(1)
)
.SelectionModel(
X.CheckboxSelectionModel()
.ID("s")
.Mode(SelectionMode.Multi)
)
.Plugins(
Html.X().CellEditing()
)
.BottomBar(
Html.X().PagingToolbar()
.HideRefresh(true)
)
.TopBar(
Html.X().Toolbar()
.Items(
Html.X().TextField()
.ID("txtSearch")
.EmptyText("Search by Module name")
.DirectEvents(de =>
{
de.Change.Action = "/search";
de.Change.ExtraParams.Add(new Parameter
{
Name = "data",
Value = "Ext.getCmp('txtSearch').getValue()",
Mode = ParameterMode.Value,
Encode = false
}
);
})
,

How do i do?If only one row is selected then only edit button is enable other wise the button is disable.

live example here
http://legalinfoservices.com/home
Purchase Management->Master Management->Material Category

Daniil
Jun 11, 2014, 5:38 AM
Hi @matrixwebtech,

I think for initial state you can set

.Disabled(true)
for the Button, because there is probably no selection.

Then I would listen to a CheckboxSelectionModel's SelectionChange event.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.selection.Model-event-selectionchange

As you can see there is the "selected" argument. It is an array of selected records. You can check length of that array and enable or disable the Button accordingly.

matrixwebtech
Jun 11, 2014, 9:03 AM
Hi @matrixwebtech,

I think for initial state you can set

.Disabled(true)
for the Button, because there is probably no selection.

Then I would listen to a CheckboxSelectionModel's SelectionChange event.
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.selection.Model-event-selectionchange

As you can see there is the "selected" argument. It is an array of selected records. You can check length of that array and enable or disable the Button accordingly.

Daniil,
Thanks for your reply.
But I am very new with EXT.NET so I am not understand how to implement the script which you provide.
I attach a screen shot and try to describe what I actually need.There are 2 records in grid,I want when only 1 row is selected then only the edit button is enable.but there are another logic,
The Logic Is
By default Edit Button is disable ,If only 1 row is selected and Edit Button "Disabled" Property set to FALSE then only the Edit Button get Enable other wise Disable.

Daniil
Jun 11, 2014, 2:00 PM
I suggest to read this about this tutorial about client side events. After reading you should be able to use Listeners.
http://www.ext.net/2012/12/19/introduction-to-ext-net-events/