Skip to content

Replies

0
Jason D.
Jason D. answered on Nov 25, 2014 2:41 PM

Hello Luis,

You are correct about all of this. The way to handle hidden columns is to add a value manually to the values collection. As for not being able to use findRecordByKey, this method is used to find a record within the dataSource. At the time of rowAdding the record hasn't been committed yet and therefore cannot be found by that approach.

0
Jason D.
Jason D. answered on Nov 20, 2014 7:53 PM

Hello Jimmy,

You are correct that the MVC helper combo editor options do not include the option to hook up the events at this time. The way to work around this and limit the event to just one of your combos is to first make sure that you set an ID for the combo in the ComboEditorOptions. Next, wire up the igcomboselectionchanged event through the use of the on function, using the patter $(<grid element selector>).on('igcomboselectionchanged', <combo element selector>, <function name>); For example:

        $(function () {
            $('#grid1').on('igcomboselectionchanged', '#FirstCombo', SelectionChanged);
        });

This syntax will make sure that the event gets wired up to the exact combo that you want it to at the time that the combo is created.

As for your second question, please note that the field that you set as the ValueKey should have the same data type as the column you are editing, which is most likely why you are seeing this behavior. Basically, the column that you are editing is set to accept string values so the value of your combo must be a string. The easiest way to resolve this issue would be to set both the TextKey and the ValueKey to cur_name.

If you would instead prefer to have cur_cd be the value of the cell then you'll need to modify the column definition so that the column matches the data type of cur_cd. Please note that after you change the value you'll see cur_cd displayed. If you want to make sure that cur_name is always displayed in that situation then the following forum thread with Martin should be useful for demonstrating how this can be implemented:

https://www.infragistics.com/community/forums/f/ignite-ui-for-javascript/72892/combo-as-editor-type-in-iggrid-column/370474#370474

Please let me know if I may be of any other help with this matter.

0
Jason D.
Jason D. answered on Nov 20, 2014 5:21 PM

Hello Luis,

The editRowEnded event exposes a property called rowID off of the ui event argument. It is recommended that you use this for accessing rows rather than the index and then pass that value to the grid’s findRecordByKey method to get access to the record you want. In the case of hierarchical grid you’re going to want to find the container grid widget for the record and then call findRecordByKey off of the widget. Fortunately, the ui also exposes the container grid in the form of ui.owner.grid. Using this, you can simplify the logic that you have to the following:

  $('#MyGrid').on('iggridupdatingeditrowended', function (evt, ui) {
    var row = ui.owner.grid.findRecordByKey(ui.rowID);
    if (row.Description) {
     // Show category's description
     console.log(row.Description);
    }
    else if (row.Name) {
     // Show the name of the edited product
     console.log(row.ShipName);
    }
   });

 

0
Jason D.
Jason D. answered on Nov 5, 2014 5:57 PM

Hello droedger,

The reason that the ItemCommand event is failing to fire is that templates of the grid are instantiated in the DataBind method of the grid. Normally if this method is not manually called it gets called during the OnPreRender event for the grid. However, when using this with the ItemCommand the DataBind event is fired after the ItemCommand event is supposed to fire. Since the templates haven't been instantiated in time the event can't find the templates and fails out silently.

The way to resolve this issue is to ensure that the templates exist. You can do this by adding the following code to your PageLoad event:

if (IsPostBack) {

   WebDataGrid1.EnsureTemplates();
}

The way that it was working previously in the older versions was not actually the intended behavior of the control. This new approach is the correct way to implement ItemCommands, TemplateColumns, and EnableDataViewState. Please let me know if you have any questions or concerns about this approach, or let me know if I may be of any other help.