首页 \ 问答 \ 如果其中有一些重音字符,则IndexOf()不起作用(IndexOf() is not working if there is some accent characters in it)

如果其中有一些重音字符,则IndexOf()不起作用(IndexOf() is not working if there is some accent characters in it)

我有datatable(dtblCostCategory),它具有以下值,我在下拉列表中使用它。 我从下拉列表中选择了值后保存了一些数据。 当我再次加载相同的页面时,未显示所选的值,而是在下拉列表中显示第一个值。

        dsOtherDetails   

        CostCategory |  typeId  |  itemCount
        ----------------------------------------
          Softwaré   |    3     |     15

        dtblCostCategory

                CostCategory |  typeId    
               ----------------------------
                Electronics  |    1
                Groceries    |    2
                Softwaré     |    3


                cboCategory.DataSource = dtblCostCategory
                cboCategory.DataTextField = dtblCostCategory.Columns(1).ToString
                cboCategory.DataValueField = dtblCostCategory.Columns(0).ToString
                cboCategory.DataBind()

                Dim lstItem As New ListItem
                lstItem.Text = Server.HtmlEncode(Trim(CStr(dsOthersDetails.Tables(0).Rows(0).Item("CostCategory"))))
                lstItem.Value = Server.HtmlEncode(CStr(dsOthersDetails.Tables(0).Rows(0).Item("typeId")))
                cboCategory.SelectedIndex = cboCategory.Items.IndexOf(lstItem)

在上面的代码中,我使用indexOf通过比较两个表中的值来获取所选索引。 由于类别(Softwaré)中有重音,indexOf无法正常工作。 有没有办法我可以选择索引忽略重音,以便下拉列表具有正确的选定值。


I have datatable(dtblCostCategory) which has the following values which i use it in the dropdown. And i have saved some data after selecting the value from the dropdown. When i load the same page again the selected value is not being shown instead the first values is shown in dropdown.

        dsOtherDetails   

        CostCategory |  typeId  |  itemCount
        ----------------------------------------
          Softwaré   |    3     |     15

        dtblCostCategory

                CostCategory |  typeId    
               ----------------------------
                Electronics  |    1
                Groceries    |    2
                Softwaré     |    3


                cboCategory.DataSource = dtblCostCategory
                cboCategory.DataTextField = dtblCostCategory.Columns(1).ToString
                cboCategory.DataValueField = dtblCostCategory.Columns(0).ToString
                cboCategory.DataBind()

                Dim lstItem As New ListItem
                lstItem.Text = Server.HtmlEncode(Trim(CStr(dsOthersDetails.Tables(0).Rows(0).Item("CostCategory"))))
                lstItem.Value = Server.HtmlEncode(CStr(dsOthersDetails.Tables(0).Rows(0).Item("typeId")))
                cboCategory.SelectedIndex = cboCategory.Items.IndexOf(lstItem)

In the above code I have used indexOf to get the selected index by comparing the values from two tables. As there is accent in category (Softwaré) the indexOf is not working properly. Is there way where I can get selected index ignoring the accents so that the drop down will have correct selected value.


原文:https://stackoverflow.com/questions/45029776
更新时间:2022-08-18 08:08

最满意答案

要获取所选行值,您可以使用:

var records = Ext.getCmp('your_grid_id').getSelectionModel().getSelection(),
record  = records.length === 1 ? records[0] : null;
alert(record.get('a_row_title'); // specified in the model

要将值设置为文本字段:

Ext.getCmp('your_textField_id').setValue(record.get('...'));

To get the selected row values you can use:

var records = Ext.getCmp('your_grid_id').getSelectionModel().getSelection(),
record  = records.length === 1 ? records[0] : null;
alert(record.get('a_row_title'); // specified in the model

To set the value to a text field:

Ext.getCmp('your_textField_id').setValue(record.get('...'));

相关问答

更多
  • forceFit本身! 该属性已从View类移至Panel 。 请参阅Ext.grid.Pane l文档。 您现在可以直接将其放入网格的配置中,而不是使用viewConfig 。 forceFit itself! The property has been moved from View class to the Panel. Refer the Ext.grid.Panel documentation. Rather than using viewConfig, you can now directly ...
  • 嘿,你的问题是你可能会返回你的json中的所有10个项目,分页支持你必须实现自己,所有分页正在做的是调用商店的负载与特定的参数,如页面的限制和页面开始索引。 您必须在后端使用这些参数才能一次发送一个项目。 Chers队友。 编辑 //this is the model we will be using in the store Ext.define('Page', { extend: 'Ext.data.Model', fields: [ {name: 'id', ty ...
  • 事实上,它仍然可用,但他们从文档中删除它,我不知道为什么。 In fact, it is still available, but they removed it from the docs, I don't know why.
  • 您需要使用StoreWriter将商店与服务器同步。 此链接可能对您有用 - 使用Ext Store Writer更新数据库 - ExtJS 4.2 You will need to sync the store with server with StoreWriter. This link might be useful to you - Updating database with Ext Store Writer - ExtJS 4.2
  • 您应该从Ext.selection.Model(可能是单元格或行)设置“select”事件。 在那种情况下,您会收到以下参数: Ext.selection.RowModel: select( Ext.selection.RowModel this, Ext.data.Model record, Number index, Object eOpts ). 所以从那里你有记录和索引,如果你想获得另一条记录(例如前一条记录),你应该从商店获得它,如下所示: record.store.getAt(index - ...
  • 要获取所选行值,您可以使用: var records = Ext.getCmp('your_grid_id').getSelectionModel().getSelection(), record = records.length === 1 ? records[0] : null; alert(record.get('a_row_title'); // specified in the model 要将值设置为文本字段: Ext.getCmp('your_textField_id').setValue ...
  • 看起来你需要转义路径数据。 应该是{路径:“C:\\ something \\”} 另外为什么不使用网格分组功能? http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.feature.Grouping 进一步看,看起来loaddata函数期待一个数组。 不是像你一样拥有rootdata对象的json对象。 将侦听器更改为以下内容: var jsondata = Ext.decode(result.responseText); documents.loadDat ...
  • 我帮你检查了ExtJS3和ExtJS4的差异,主要的变化是focusEl已从gridView元素中删除。 在ExtJS3中,focusEl是视图中的锚链接
    stratboogie在http://www.sencha.com/forum/showthread.php?151442-Nested-EXTJS-4-Grids的回答完成了这项工作。 我做了一些修改,将Element ID存储到一个数组中 subGrids.push(subGrid.id); 然后覆盖分页事件处理程序以循环遍历数组并使用数组内的ID销毁所有元素以保持内存的检查。 function destroySubGrids(){ Ext.each(subGrids, function(id ...
  • 我对DWR一无所知,但是通过模拟你的代码我们可以看到回调是作为你的getList()方法的第一个参数传递的,但它期望它作为第三个参数。 回调参数的位置实际上取决于代理的dwrParams配置选项: // adding parameters if there are defined any in proxy // configuration if (typeof (me.dwrParams) === 'object') { dwrParams = dwrParams.concat(me.dwrPara ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)