PDA

View Full Version : [CLOSED] Knowing the Grid who's sending the Record



sisa
Mar 19, 2013, 11:12 AM
Hi all

I try to write a generic method to add column editors to our grid's.
It not a big thing to do that...


'Edit Column
Dim editColumn As New CommandColumn
editColumn.ID = grid.ID & "colEdit"
editColumn.Width = New Unit(120)

If columns.Contains(EditColumns.Edit) Then
Dim editCommand As New GridCommand
editCommand.CommandName = "cmdEdit"
editCommand.Icon = Icon.Pencil
editColumn.Commands.Add(editCommand)
End If

If columns.Contains(EditColumns.Delete) Then
Dim delCommand As New GridCommand
delCommand.CommandName = "cmdDelete"
delCommand.Icon = Icon.Delete
editColumn.Commands.Add(delCommand)
End If

editColumn.Listeners.Command.Handler = "handleItem(command, record);"

'Add the Edit Column as 2nd Col after the hidden Id Col
grid.ColumnModel.Columns.Insert(1, editColumn)

The only problem i face now, is to know which grid sends the record. I've got 9 grid on the view and each one has this edit columns added with the code above.

The JS function looks like this :


function handleItem(command, record) {

switch (command) {
case 'cmdAdd':
addItem(command, record);
break;

case 'cmdDelete':
deleteItem(command, record);
break;

case 'cmdEdit':
editItem(command, record);
break;

default:
}

};

Is there a way to resolve the grid that sends the command ?

Peter

Daniil
Mar 19, 2013, 11:28 AM
Hi Peter,

Please use:

editColumn.Listeners.Command.Handler = "handleItem(command, record, this.grid);"

function handleItem(command, record, grid)

sisa
Mar 19, 2013, 11:54 AM
Hi Peter,

Please use:

editColumn.Listeners.Command.Handler = "handleItem(command, record, this.grid);"

function handleItem(command, record, grid)

LOL - Life can be so easy :-)