The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

Using record.set() in a RENDER function produces "undefined" ERROR

  1. #1

    Using record.set() in a RENDER function produces "undefined" ERROR

    I´m trying to change value of a grid's column by rendering it. (I don´t know if it's a valid way to do).

    I'm using record.set(metadata.id, resultado); and produces next error ( Error en tiempo de ejecución de Microsoft JScript: 'undefined' es nulo o no es un objeto)

    I also used record.data.RequestQty = resultado; instead the "set" method, and all was OK, BUT... I need the cell marked as dirty, that's why I need to use the set function, I also try to use the record.dirty = true; and also produces an error ( Error en tiempo de ejecución de Microsoft JScript: 'modified' es nulo o no es un objeto )

    I hope anyone can HELP... Thanks

    <script type="text/javascript">
            var requestQty = function (value, metadata, record, rowIndex, colIndex, store) {
                if (value == '0' || value == '') {
                    result = parseFloat(record.data.PlannedQty) - parseFloat(record.data.NeededQty);
                    if (result > 0) {
                        //record.data.RequestQty = result;
                        //record.dirty = true;
                        record.set(metadata.id, result);
                        return Ext.util.Format.number(result, "0,000,000,000.0000");
                    }
                } else {
                    return Ext.util.Format.number(value, "0,000,000,000.0000");
                }
            }
    </script>

    <ext:GridPanel 
        ID="grdProductosOrdenFabricacion" 
        runat="server" 
        StoreID="stoOrdenFabricacionDetalle" 
        StripeRows="true"
        Title="" 
        TrackMouseOver="true" 
        AutoExpandColumn="ItemName" 
        Header="false" 
        BodyBorder="false" 
        Frame="false"
        ClicksToEdit="1" >
        <ColumnModel ID="ColumnModel1" runat="server">
            <Columns>
                <ext:Column 
                    ColumnID="ItemCode" 
                    DataIndex="ItemCode"
                    Header="Código Artículo" 
                    Width="100" />
                <ext:Column ColumnID="ItemName" 
                    DataIndex="ItemName"
                    Header="Descripción del Artículo" />
                <ext:Column 
                    ColumnID="IssueType" 
                    DataIndex="IssueType"
                    Header="Método<br />Emisión"
                    Align="Center"
                    Width="70" />
               <ext:Column 
                    ColumnID="PlannedQty" 
                    DataIndex="PlannedQty"
                    Header="Cantidad<br />Requerida" 
                    Align="Center"
                    Width="100" />
                <ext:Column 
                    ColumnID="NeededQty" 
                    Header="Cantidad<br />Solicitada" 
                    DataIndex="NeededQty"
                    Align="Center"
                    Width="100" />
                <ext:Column 
                    ColumnID="RequestQty" 
                    Header="Cantidad<br />Por Solicitar" 
                    DataIndex="RequestQty"
                    Align="Center"
                    Width="100" >
                    <Editor>
                        <ext:NumberField 
                            runat="server"
                            ID="txtCantidadPorSolicitar"
                            AllowNegative="false" 
                            AllowBlank="false" 
                            DecimalPrecision="4"
                            SelectOnFocus="true">
                        </ext:NumberField>
                    </Editor> 
                    <Renderer fn="requestQty"/>
                </ext:Column>
            </Columns>
        </ColumnModel>
        <View>
            <ext:GridView ID="gvwProductosOrdenFabricacion" runat="server">
                <GetRowClass Fn="formateaFilaOrdenFabricacionDetalle" />
            </ext:GridView>
        </View>
        <SelectionModel>
            <ext:RowSelectionModel
                ID="RowSelectionModel1"
                runat="server"
                SingleSelect="true" >
            </ext:RowSelectionModel>
        </SelectionModel>
        <Listeners>
            <BeforeEdit Handler="if(e.record.data.IssueType == 'Notificación' && e.field=='CantidadPorSolicitar'){
                                                  msgWarningTitulo('Advertencia', 'Los Productos de Notificación no pueden ser Modificados');
                                                  e.cancel = true;
                                              }" />
        </Listeners>
        <LoadMask ShowMask="true" />
    </ext:GridPanel>
  2. #2
    Hi,

    'metadata' consists .css and .attr properties, there is no .id property.
    http://dev.sencha.com/deploy/ext-3.3...ember=renderer

    To update a record's id, please use the store's .updateRecordId() method.
    store.updateRecordId(record, result);
  3. #3
    Hi Daniil, thanks for your answer, but...

    My goal is not to update the records's Id, I want to update the value of a determinated field... In this case "metadata.id" has the name of that record's field... as you can see in the image I provide. I can change the metadata.id code line for

    record.set("CantidadPorSolicitar", resultado);
    And the error Occurs...

    Click image for larger version. 

Name:	Error.jpg 
Views:	145 
Size:	95.2 KB 
ID:	2786Click image for larger version. 

Name:	Metadata.jpg 
Views:	140 
Size:	100.2 KB 
ID:	2787

    Is any other way to change the grid's value and mark the cell as dirty ?

    Thanks
  4. #4
    Hi Again...

    I solved my problem replacing the .set code Line

    record.set(metadata.id, resultado);
    By

    record.data.CantidadPorSolicitar = resultado;
    record.markDirty();
    Thanks for the link you provide me Daniil... I found the answer there in the API doc
  5. #5
    Quote Originally Posted by Daniil View Post
    'metadata' consists .css and .attr properties, there is no .id property.
    Really, I was wrong there is the .id property, not sure why it's absent in the docs.

    Anyway, this .id property doesn't consist a field's name (iow .dataIndex), it consist a column's id if it's set in a config or a column's index.

    In your case metadata.id doesn't consist 'CantidadPorSolicitar'.

    Why don't you want to use just this code?
    record.set('CantidadPorSolicitar', resultado);
    To avoid hardcoded things you can use ColumnModel's API to get a column's .dataIndex from metadata.id.
  6. #6
    Hi Daniill...

    Using

    record.set('CantidadPorSolicitar', resultado);
    Produces this error ... Error en tiempo de ejecución de Microsoft JScript: 'undefined' es nulo o no es un objeto

    See the image attached

    Click image for larger version. 

Name:	Error.jpg 
Views:	119 
Size:	95.2 KB 
ID:	2788
  7. #7
    Oh, sure, .set() method causes grid refreshing - it's not the best thing in Renderer:)

    I should say that it's not a good solution to change values of another columns within Renderer. But sure that there is another way to achieve your requirement.
  8. #8
    The Solution to my problem was... change the .set() method to...

    record.data.CantidadPorSolicitar = resultado; 
    record.markDirty();
    Thanks
  9. #9
    Ok, glad to help.

Similar Threads

  1. Replies: 4
    Last Post: Aug 24, 2011, 11:29 AM
  2. Replies: 4
    Last Post: Apr 29, 2011, 6:49 PM
  3. Replies: 9
    Last Post: Apr 25, 2011, 8:23 PM
  4. Replies: 12
    Last Post: Apr 13, 2011, 3:28 PM
  5. Replies: 14
    Last Post: Apr 12, 2011, 2:49 PM

Tags for this Thread

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.