public void AddSelectedItem(T item) { var itemWidget = Browser.Document.CreateElement("div"); itemWidget.Style.WhiteSpace = "nowrap"; itemWidget.Style.FontSize = "60%"; itemWidget.Style.Border = "1px black solid"; itemWidget.Style.BorderRadius = "5px"; itemWidget.Style.PaddingLeft = "3px"; itemWidget.Style.PaddingRight = "3px"; itemWidget.Style.Cursor = "default"; itemWidget.Title = "Click to remove"; itemWidget.AddEventListener("click", evt => { RemoveSelectedItem(item); contentNode.Focus(); }); itemWidget.AppendChild(Browser.Document.CreateTextNode(textProvider(item))); var itemCell = Browser.Document.CreateElement("td"); itemCell.Style.PaddingLeft = "2px"; itemCell.AppendChild(itemWidget); itemCell.InsertBefore(contentNodeCell); selectedWidgets[item] = itemWidget; selectedItems.Add(item); }
/// <summary> /// This method allows us to specify a cell and set focus to one of its neighboring cells /// </summary> /// <param name="id">Text Input Element id for the source cell</param> /// <param name="horizontal">Direction to move horizontally. Negative value moves left.</param> /// <param name="vertical">Direction to move vertically. Negative value moves up.</param> private void SetFocusFromCellTo(string id, int horizontal, int vertical) { int row = int.Parse(id.Substring(1)); string column = id.Substring(0, 1); InputElement element = Document.GetElementById <InputElement>(string.Format("{0}{1}", string.FromCharCode(column.CharCodeAt(0) + horizontal), row + vertical)); if (element != null) { element.Focus(); } }