Announcement

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

    #16
    We've made changes to prevent sortChanged() from firing in these circumstances (at initialization, via sortField/sortState/initialSort).

    However, note that the examples you provided are invalid:

    1) a ListGrid will not produce state that has a sort fieldName but not a sortDir (although this may have been conceivable in the past) - if you manually construct such state, the grid will assume the default sortDirection. Note that the fieldName/sortDir aspects of sort-state are legacy attributes - you should use sortSpecifiers for better control.

    2) a ListGrid will not (in recent versions) produce state like "sort: {}" - if you manually provide such invalid state, the grid will clear it's sort-specification, potentially unsort()ing the data.

    Comment


      #17
      Hey guys,

      it’s working now with list grids without datasource. But when working with a datasource, the sortChanged event still gets fired when setting a view state including sort specifiers.

      Following a small example based on one of yours:
      (http://smartclient.com/docs/10.0/a/s...taSourceFields)

      fieldsDS.js
      Code:
      isc.ListGrid.create({
      	ID : "countryList",
      	sortChanged : function () {
      		isc.say("SortChanged")
      	},
      	width : 500,
      	height : 224,
      	alternateRecordStyles : true,
      	dataSource : countryDS,
      	autoFetchData : true,
      	viewState : ({
      		field : [{
      				name : "countryName"
      			}, {
      				name : "countryCode"
      			}, {
      				name : "independence",
      				width : 80
      			}, {
      				name : "population"
      			}, {
      				name : "gdp"
      			}
      		],
      		sort : {
      			fieldName : "countryName",
      			sortDir : "ascending",
      			sortSpecifiers : [{
      					property : "countryName",
      					direction : "ascending"
      				}
      			]
      		}
      	})
      })
      This issue occurres in the latest nightly build of smartclient (SmartClient_v100p_2015-02-09_Pro) and happens in all current browsers (Firefox, Chrome and IE)

      Best Regards

      Comment


        #18
        Ok, that's been fixed also - please retest with a build dated February 11 or later.

        Comment


          #19
          Hey guys,

          thanks for your fix, but there is still an issue with the sortChanged event. When setting the view state after initialization via setViewState(), the sortChanged event fires. This even happens if the given sort field and direction of the listgrid is the same as in the view state.

          The sortChanged event should behave like all other events and should only fire when the user manipulates the sort specifiers.

          Following two examples the first is a list grid without given sort specifiers, the second has the same sort specifiers as the set view state.

          List grid without given sort specifiers
          Code:
          isc.ListGrid.create({
          	"ID" : "listGrid",
          	"fieldStateChanged" : function (record, state) {
          		isc.say("sortChanged")
          	},
          	dataSource : isc.DataSource.create({
          		"fields" :
          		[{
          				"name" : "term"
          			}, {
          				"name" : "level"
          			}
          		],
          		"dataFormat" : "json",
          		"useHttpProxy" : false,
          		"dataURL" : "http://devset.de/proxy.php?mode=native&url=" + encodeURI("www.openthesaurus.de/synonyme/aber?format=application/json"),
          		"recordXPath" : "/synsets[3]/terms"
          	}),
          	"autoFetchData" : true,
          	"dataPageSize" : 30,
          	"members" :
          	[]
          });
          listGrid.setViewState(({
          		field : [{
          				name : "term"
          			}, {
          				name : "level"
          			}
          		],
          		sort : {
          			fieldName : "term",
          			sortDir : "descending",
          			sortSpecifiers : [{
          					property : "term",
          					direction : "descending"
          				}
          			]
          		}
          	}))
          Same list grid with given sort specifiers
          Code:
          isc.ListGrid.create({
          	"ID" : "listGrid",
          	"sortField" : "term",
          	"sortDirection" : "descending",
          	"fieldStateChanged" : function (record, state) {
          		isc.say("sortChanged")
          	},
          	dataSource : isc.DataSource.create({
          		"fields" :
          		[{
          				"name" : "term"
          			}, {
          				"name" : "level"
          			}
          		],
          		"dataFormat" : "json",
          		"useHttpProxy" : false,
          		"dataURL" : "http://devset.de/proxy.php?mode=native&url=" + encodeURI("www.openthesaurus.de/synonyme/aber?format=application/json"),
          		"recordXPath" : "/synsets[3]/terms"
          	}),
          	"autoFetchData" : true,
          	"dataPageSize" : 30,
          	"members" :
          	[]
          });
          listGrid.setViewState(({
          		field : [{
          				name : "term"
          			}, {
          				name : "level"
          			}
          		],
          		sort : {
          			fieldName : "term",
          			sortDir : "descending",
          			sortSpecifiers : [{
          					property : "term",
          					direction : "descending"
          				}
          			]
          		}
          	}))
          This is reproducable with the latest nightly SmartClient_v100p_2015-02-11_Pro and happens in all current browsers (Firefox, Chrome and IE)

          Best Regards

          Comment


            #20
            We've made an alteration, such that sortChanged() will no longer fire unless the new sort-specification is actually different from the existing one.

            This addresses your second example below.

            On your first example - since there is no existing sort-specification, the sortSpecifiers being applied are indeed different, so the notification fires.

            It sounds as though you're expecting that sorting initialized from state should *never* fire this notification? We're not sure we agree with that.

            And you other point about sortChanged() only firing "when the user manipulates the sort specifiers" - we don't agree with that either - for example, sorting may be disabled for the user with canSort:false, but an external call to setSort() could still change the sortSpecifiers.

            Comment

            Working...
            X