setSortFieldName sets sorting to happen on given field and direction see [Table.sortFieldName] for details.
(nm string)
| 443 | // setSortFieldName sets sorting to happen on given field and direction |
| 444 | // see [Table.sortFieldName] for details. |
| 445 | func (tb *Table) setSortFieldName(nm string) { |
| 446 | if nm == "" { |
| 447 | return |
| 448 | } |
| 449 | spnm := strings.Split(nm, ":") |
| 450 | got := false |
| 451 | for fli := 0; fli < tb.numVisibleFields; fli++ { |
| 452 | fld := tb.visibleFields[fli] |
| 453 | if fld.Name == spnm[0] { |
| 454 | got = true |
| 455 | // fmt.Println("sorting on:", fld.Name, fli, "from:", nm) |
| 456 | tb.sortIndex = fli |
| 457 | } |
| 458 | } |
| 459 | if len(spnm) == 2 { |
| 460 | if spnm[1] == "down" { |
| 461 | tb.sortDescending = true |
| 462 | } else { |
| 463 | tb.sortDescending = false |
| 464 | } |
| 465 | } |
| 466 | if got { |
| 467 | tb.SortSlice() |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | // RowGrabFocus grabs the focus for the first focusable widget in given row; |
| 472 | // returns that element or nil if not successful. Note: grid must have |
no test coverage detected