[2.1] GridPanelFor Batch Update

Page 2 of 3 FirstFirst 123 LastLast
  1. #11
    While we wait for an answer by one of the dev team, how do you set the IDas nullable?

    Thanks..
  2. #12
    Quote Originally Posted by millenovanta View Post
    While we wait for an answer by one of the dev team, how do you set the IDas nullable?

    Thanks..
    You can use the int? type (nullable int) and add the UseNull=true parameter in the ModelField Attribute like in the model in the example.

       
            [ModelField(IDProperty=true, UseNull=true)]
            [Field(Ignore=true)]
            public int? Id
            {
                get;
                set;
            }
  3. #13
    Well, I put the question because I already have those settings, but it does not work anywhere...
    I also do not understand why that "[Field(Ignore=true)]" does not make the field as ignored...

    And I don't find any doc speaking about those properties...

    Is it worth for you to send me your solution (also by email), to see what is different?

    Thank you!
  4. #14
    I debugged a bit again, and it seems that methods getNewRecords and getUpdatedRecords, on which is built the getChangedRecords, return an empty array.

    So, it seems that he cannot be able to recognise that on the store there are new or changed records...
  5. #15
    I've resolved, apparently:

    All fields that are not defined as nullable, should not be null, otherwise they will not be saved.

    Unfortunately strings cannot be nullable...
  6. #16
    The problem that if simple type field (bool, int, double) is not nullable then it marks as required automatically.
    It should not be required for id fields. I would consider it as bug

    We will investigate it
  7. #17
    Try to replace CreateModelFieldFromMeta method in Ext.Net\MVC\Ext\Data\Store.cs' by the following code

    public static ModelField CreateModelFieldFromMeta(ModelMetadata propertyMetadata, Ext.Net.Model storeModel = null, ModelFieldAttribute modelAttr = null, ControllerContext controllerContext = null)
            {
                var modelField = new ModelField();
                if (modelAttr == null)
                {
                    modelAttr = propertyMetadata.AdditionalValues.ContainsKey(ModelFieldAttribute.KEY) ? (ModelFieldAttribute)propertyMetadata.AdditionalValues[ModelFieldAttribute.KEY] : null;
                }           
    
    
                modelField.Name = propertyMetadata.PropertyName;
                modelField.Type = TypeUtils.MappingModelFieldType(propertyMetadata.ModelType);
    
    
                if (propertyMetadata.IsComplexType && modelAttr != null)
                {
                    modelField.IsComplex = true;
                }
    
    
                if (modelAttr != null && storeModel != null)
                {
                    modelAttr.CopyTo(modelField, storeModel);
                }
    
    
                if(storeModel != null)
                {
                    storeModel.Fields.Add(modelField);
                }
    
    
                ValidationCollection validations = new ValidationCollection();
                if (propertyMetadata.AdditionalValues.ContainsKey(AbstractValidationAttribute.KEY))
                {
                    validations = (ValidationCollection)propertyMetadata.AdditionalValues[AbstractValidationAttribute.KEY];                
                }            
    
    
                if (controllerContext != null)
                {
                    foreach (ModelValidator v in propertyMetadata.GetValidators(controllerContext))
                    {
                        var rule = v.GetClientValidationRules().FirstOrDefault();
    
    
                        if (rule != null)
                        {
                            switch (rule.ValidationType)
                            {
                                case "required":
                                    if (storeModel.IDProperty != modelField.Name)
                                    {
                                        validations.Add(new PresenceValidation { Field = modelField.Name, Message = rule.ErrorMessage });
                                    }
                                    break;
                                case "regex":
                                    if (rule.ValidationParameters.ContainsKey("pattern"))
                                    {
                                        validations.Add(new FormatValidation { Field = modelField.Name, Matcher = rule.ValidationParameters["pattern"].ToString(), Message = rule.ErrorMessage });
                                    }
                                    break;
                                case "length":
                                    var lengthVal = new LengthValidation();
                                    if (rule.ValidationParameters.ContainsKey("max"))
                                    {
                                        lengthVal.Max = (int)Convert.ChangeType(rule.ValidationParameters["max"], typeof(int));
                                    }
    
    
                                    if (rule.ValidationParameters.ContainsKey("min"))
                                    {
                                        lengthVal.Min = (int)Convert.ChangeType(rule.ValidationParameters["min"], typeof(int));
                                    }
    
    
                                    lengthVal.Message = rule.ErrorMessage;
                                    validations.Add(lengthVal);
                                    break;
                            }
                        }
                    }
                }
    
    
                if (validations.Count > 0)
                {
                    if (storeModel != null)
                    {
                        storeModel.Validations.AddRange(validations);
                    }
                    else
                    {
                        modelField.Validations = validations;
                    }
                }
    
    
                return modelField;
            }
  8. #18
    It doesn't find the TypeUtils class...

    I can ask for another thing, related to the conversion of the GridPanel batch sample, to GridPanelFor?
    In the controller of the sample, is used the GetCmp method with the id of the store.
    Since I cannot use IDs in my solution, I tried getting the grid and doing

    myGrid.GetStore();

    but it returns null.

    Why it? Can't I bring up the store with that method?

    I also noticed that I can't bring up the store (of the GridPanelFor control), by his auto-generated ID, because he doesn't have an auto-generated ID.
    Which the best way to have the store in the controller? Getting the Grid and doing GetStore() (null?), or there is a way to enable auto-generation of store id and getting it by that?

    Thank you.
  9. #19
    GetCmp just creates proxy object (empty instance of required type) and load submitted data to that control
    It doesn't recreate control from the view because it has no access to the view
  10. #20
    Ok. So I have to get directly the store via GetCmp...

    How store ID is controlled in GridPanelFor? It seems that it has not an auto-generated id...
    There is a way to have an unique, auto-generated ID on the store?
    Is enaugh to use IDMode? How can I set it?

    Thanks.
Page 2 of 3 FirstFirst 123 LastLast

Similar Threads

  1. [CLOSED] MVC Grid Batch Editing
    By adelaney in forum 2.x Legacy Premium Help
    Replies: 19
    Last Post: Sep 27, 2012, 5:55 AM
  2. [CLOSED] How to show mask on ajax update panel update
    By egvt in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: May 18, 2012, 9:36 PM
  3. [CLOSED] Update displayfield on directevents, update its size
    By SouthDeveloper in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 16, 2011, 9:57 PM
  4. Replies: 2
    Last Post: Jun 16, 2011, 6:50 AM
  5. [CLOSED] Update ASP Update Panel with Direct Event
    By sharif in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jun 24, 2010, 12:48 AM

Tags for this Thread

Posting Permissions