Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FormItem.getSelectedRecord() functionality is exist ListGridField? (Example ListGridField.getSelectedRecord())

    We getting record, returned optionDatasource, when using combobox in dynamicForm by FormItem.getSelectedRecord(). We want to use same function, when using combobox in ListGrid. Because We already getting detail information by optionDatasource from server. So we don't need to go to server second time.

    This example demonstrates, usage of FormItem.getSelectedRecord() in dynamicForm. We want to similar usage in ListGrid.

    Code:
    //Creating dataSource
    function createDataSource(operationBindings, fields) {
    
        return isc.RestDataSource.create({
            dataFormat: "json",
            operationBindings: operationBindings,
            jsonPrefix: "//'\"]]>>isc_JSONResponseStart>>",
            jsonSuffix: '//isc_JSONResponseEnd',
            fields: fields       
        });
    }
    
    //Summary optionDataSource
    var dsSummaryMuhasebeRecords = createDataSource(
            [
                { operationType: "fetch", dataProtocol: "postMessage", dataURL: "../Muhasebe/GetSummaryMuhasebeHareketleri?SirketKodu=" + parameters.sirketKodu.toString() }
            ],
            [
                { name: "KayitKoduId", type: "number", visibility: false },
                { name: "KayitKodu", title: "Kayıt Kodu", type: "text" },
                { name: "FisTarihi", title: "Fiş Tarihi", type: "date" },
                { name: "FisNumarasi", title: "Fiş Numarası", type: "integer" },
            ]
        );
    
    var frmFisMasterBilgileri = isc.DynamicForm.create({
            autoDraw: false,
            width: "100%",
            height: "50",
            numCols: 6,
            colWidths: [100, 100, 100, 100, 100, 100],
            isGroup: true,
            groupTitle: "Muhasebe Master Bilgileri",
            showResizeBar: true,
            fields: [
                {
                    name: "KayitKoduId", title: "Kayıt Kodu", editorType: "ComboBoxItem",
                    optionDataSource: dsKayitKodlari, wrapTitle: false,
                    displayField: "KayitAdi", valueField: "Id",
                    pickListWidth: 300,
                    pickListFields: [
                        { name: "KayitKodu" },
                        { name: "KayitAdi" }
                    ],
                    pickListProperties: {
                        showFilterEditor: true
                    },
                    click: function (form, item) {
                        form.setValue("FisNumarasi", "");
                    }
                },
                {
                    name: "FisTarihi", title: "Fiş Tarihi", editorType: "DateItem",
                    click: function (form, item) {
                        form.setValue("FisNumarasi", "");
    
                    }
                },
                {
                    name: "FisNumarasi", title: "Fiş Numarası", type: "integer", editorType: "ComboBoxItem",
                    optionDataSource: dsSummaryMuhasebeRecords, wrapTitle: false,
                    displayField: "FisNumarasi", valueField: "FisNumarasi",
                    pickListWidth: 300,
                    pickListProperties: {
                        showFilterEditor: true
                    },
                    pickListFields: [
                        { name: "KayitKodu" },
                        { name: "FisTarihi" },
                        { name: "FisNumarasi" }
                    ],
                    //****************** EXAMPLE USAGE ********************************
                    changed: function (form, item, value) {
    
                        //getting selectedRecord from optionDatasource
                        var selectedRecord = item.getSelectedRecord();
    
                        //set value in form, selectedRecord.KayitKoduId
                        form.setValue("KayitKoduId", selectedRecord.KayitKoduId);
    
                        //set value in form, selectedRecord.FisTarihi
                        form.setValue("FisTarihi", selectedRecord.FisTarihi);
                    }
                    //****************** EXAMPLE USAGE ********************************
                }
            ]
        });

    #2
    If you add a changed() handler via ListGridField.editorProperties then it works the same as it does on FormItem - the formItem innstance is passed in, and you can call getSelectedRecord() on it.

    Comment


      #3
      Hello. Thanks for answer. Its works. But i added .editorProperties to ListGridField object after that original "changed" methods not working. So filtering on comboBox item on grid not working. If i used this.Super() method, nothing changes.
      How can i fix this problem.

      Code:
      //******************************ListGridField Object*********************************
      
      {
                      name: "HesapPlaniId", title: "Hesap Planı Kodu", type: "comboBox",
                      optionDataSource: dsHesapPlaniListesi, displayField: "HesapAdi", valueField: "Id",
                      filterFields: ["HesapPlaniKodu", "HesapAdi"],
                      pickListWidth: 300,
                      pickListFields: [
                          { name: "HesapPlaniKodu" },
                          { name: "HesapAdi" },
                          { name: "HesapBaglantiTipi" }
                      ],
                      pickListProperties: {
                          showFilterEditor: true
                      },               
                      editorProperties: {
      
                          //***************************** Changed function ***************************************//
                          changed: function (form, item, value) {
      
                              this.Super("changed", arguments);
      
                              var selectedRecord = item.getSelectedRecord();
                              if (selectedRecord.HesapBaglantiTipi === "C") {
                                  form.grid.showField("CariTipiId");
                                  form.grid.showField("CariKoduId");
                              };
                              if (selectedRecord.HesapBaglantiTipi === "D") {
                                  form.grid.showField("DepartmanKoduId");
                                  form.grid.showField("AltMasrafMerkeziTipiId");
                                  form.grid.showField("AltMasrafMerkeziKoduId");
                              };
      
                          }
      
                      },
                      validators: [
                          {
                              type: "required", errorMessage: "Hesap planı alanı boş geçilemez!"
                          }
                      ]
      
                  }
      Before change editorProperties.changed event

      Click image for larger version

Name:	FilteringWorking.png
Views:	87
Size:	36.6 KB
ID:	250955
      After change editorProperties.changed event

      Click image for larger version

Name:	FilteringNotWorking.png
Views:	77
Size:	31.2 KB
ID:	250956

      Comment


        #4
        We're not sure what you're saying is broken - for the "not working" case you're showing the complete absence of a dropdown, so are you saying that clicking no longer causes the dropdown to appear?

        It also appears you are not posting your real code, as you are supposedly showing a listGridField, but you have declared properties such as pickListFields, pickListWidth etc - these would only be valid in the editorProperties, not directly on the ListGridField.

        Try modifying one of our samples to add the "changed" event and properly add pickList configuration - then you'll be able to show us working code that reproduces the issue (if it's reproducible!).

        Comment

        Working...
        X